Part Number Hot Search : 
AN7710SP 17015A HER303G R1005 LB636D7Y M3202 R3119N 74270021
Product Description
Full Text Search
 

To Download ST72T101G1B3 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  september 1999 1/84 st72101/st72212/st72213 8-bit mcu with 4 to 8k rom/otp/eprom, 256 bytes ram, adc, wdg, spi and 1 or 2 timers datasheet n user program memory (rom/otp/eprom): 4 to 8k bytes n data ram: 256 bytes, including 64 bytes of stack n master reset and power-on reset n run, wait, slow, halt and ram retention modes n 22 multifunctional bidirectional i/o lines: 22 programmable interrupt inputs 8 high sink outputs 6 analog alternate inputs 10 to 14 alternate functions emi filtering n programmable watchdog (wdg) n one or two 16-bit timers, each featuring: 2 input captures 2 output compares external clock input (on timer a only) pwm and pulse generator modes n synchronous serial peripheral interface (spi) n 8-bit analog-to-digital converter (6 channels) (st72212 and st72213 only) n 8-bit data manipulation n 63 basic instructions n 17 main addressing modes n 8 x 8 unsigned multiply instruction n true bit manipulation n complete development support on pc/dos- windows tm real-time emulator n full software package on dos/windows tm (c-compiler, cross-assembler, debugger) device summary so28 psdip32 csdip32w (see ordering information at the end of datasheet) features st72101g1 st72101g2 st72213g1 st72212g2 program memory- bytes 4k 8k 4k 8k ram (stack) - bytes 256 (64) 16-bit timers one one one two adc no no yes yes other peripherals watchdog, spi operating supply 3 to 5.5 v cpu frequency 8mhz max (16mhz oscillator) - 4mhz max over 85 c temperature range - 40 c to + 125 c package so28 - sdip32 1 rev. 1.7
2/84 table of contents 95 1 general description . . . . . . ................................................ 4 1.1 introduction . . . . . . . . . . . . . ............................................ 4 1.2 pin description . . ..................................................... 5 1.3 external connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......... 9 1.4 memory map . . . . . . . . . . ........................................... .... 10 2 central processing unit . . ............................................... 13 2.1 introduction . . . . . . . . . . . . . ........................................... 13 2.2 main features . . . . . . . . . . . . . . . . . . . . . . . . . .............................. 13 2.3 cpu registers . . . .................................................... 13 3 clocks, reset, interrupts & power saving modes . . . . . . . . . . . . . ........... 16 3.1 clock system . . . . . . . . . . . . . ........................................... 16 3.1.1 general description . . . . . . ........................................... 16 3.2 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .............................. 17 3.2.1 introduction . . . .................................................... 17 3.2.2 external reset . . . . . . ........................................... .... 17 3.2.3 reset operation . . . . . . . . . . . . . . . . . . . . . . . . . ........................... 17 3.2.4 power-on reset .................................................... 17 3.3 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.4 power saving modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........ 21 3.4.1 introduction . . . .................................................... 21 3.4.2 slow mode . . . . . . . . . . . . . . . . . . . . . . . ................................. 21 3.4.3 wait mode . . . . . . . . . . . . . . . . ........................................ 21 3.4.4 halt mode . . . . . .................................................... 22 3.5 miscellaneous register . . . . . . . . . . . .................................. 23 4 on-chip peripherals . . . . . . . . . . . ........................................... 24 4.1 i/o ports . . . . . . . . . . . . . . . . . . ........................................... 24 4.1.1 introduction . . . .................................................... 24 4.1.2 functional description . . . . ........................................... 24 4.1.3 i/o port implementation . . . . . . . . . . . . . . . . . . . ........................... 25 4.1.4 register description . . . . . . ........................................... 28 4.2 watchdog timer (wdg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.2.1 introduction . . . .................................................... 30 4.2.2 main features . . . . . . ........................................... .... 30 4.2.3 functional description . . . . ........................................... 31 4.2.4 low power modes . . . ............................................... 31 4.2.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . ................................. 31 4.2.6 register description . . . . . . ........................................... 31 4.3 16-bit timer . . . . . . . . . . . . . . . . . . ........................................ 32 4.3.1 introduction . . . .................................................... 32 4.3.2 main features . . . . . . ........................................... .... 32 4.3.3 functional description . . . . ........................................... 32 4.3.4 low power modes . . ............................................... 43 4.3.5 interrupts . . . . . ................................. ................... 43 4.3.6 register description . . . . . . ........................................... 44 2
3/84 table of contents 4.4 serial peripheral interface (spi) . . . . . . . . . . . . . . . . . . . . . . . . . ........... 49 4.4.1 introduction . . . .................................................... 49 4.4.2 main features . . . . . . ........................................... .... 49 4.4.3 general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.4.4 functional description . . . . ........................................... 51 4.4.5 low power modes . . . ............................................... 58 4.4.6 interrupts . . . . . ................................. ................... 58 4.4.7 register description . . . . . . ........................................... 59 4.5 8-bit a/d converter (adc) . . . . . . . . . . . . . . . . . . ........................... 62 4.5.1 introduction . . . .................................................... 62 4.5.2 main features . . . . . . ........................................... .... 62 4.5.3 functional description . . . . ........................................... 63 4.5.4 low power modes . . . ............................................... 63 4.5.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . ................................. 63 4.5.6 register description . . . . . . ........................................... 64 5 instruction set . . . . . . . . . . . . . . . . . . ........................................ 65 5.1 st7 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.1.1 inherent . . . . . . . . . . . ........................................... .... 66 5.1.2 immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 5.1.3 direct . ........................................................... 66 5.1.4 indexed (no offset, short, long) . . . . . . . . . . . . ........................... 66 5.1.5 indirect (short, long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 5.1.6 indirect indexed (short, long) . ........................................ 67 5.1.7 relative mode (direct, indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.2 instruction groups . . . . . . . . . . . . . . . . ............................. .... 68 6 electrical characteristics . . . . . . . . . . . . . . . . .............................. 71 6.1 absolute maximum ratings . . . ........................................ 71 6.2 recommended operating conditions . . . .............................. 72 6.3 dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . ........... 73 6.4 reset characteristics . . . . . . . . . . .................................... 74 6.5 oscillator characteristics . . . . . . . . . . . .............................. 74 6.6 a/d converter characteristics (st72212 and st72213 only) . . . ........ 75 6.7 spi characteristics . . ........................................... .... 77 7 general information . . . . . . . . . . ........................................... 80 7.1 eprom erasure . . . . . . . . . . . . . . . . . . . . . . . . .............................. 80 7.2 package mechanical data . . . . . . . . . . . . . . . . . ........................... 80 7.3 ordering information . . . . . . . . . . . . . .................................. 82 7.3.1 transfer of customer code . . . . . . . . . . . . . . . . . . . . . . . . . . . . ............... 82 8 summary of changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 3
4/84 st72101/st72212/st72213 1 general description 1.1 introduction the st72101, st72213 and st72212 hcmos microcontroller units are members of the st7 family. these devices are based on an industry- standard 8-bit core and feature an enhanced instruction set. they normally operate at a 16mhz oscillator frequency. under software control, the st72101, st72213 and st72212 may be placed in either wait, slow or halt modes, thus reducing power consumption. the enhanced instruction set and addressing modes afford real programming potential. in addition to standard 8-bit data management, the st72101, st72213 and st72212 feature true bit manipulation, 8x8 unsigned multiplication and indirect addressing modes on the whole memory. the devices include an on-chip oscillator, cpu, program memory (rom/otp/eprom versions), ram, 22 i/o lines and the following on-chip peripherals: analog-to- digital converter (adc) with 6 multiplexed analog inputs (st72212 and st72213 only), industry standard synchronous spi serial interface, digital watchdog, one or two independent 16-bit timers, one featuring an external clock input, and both featuring pulse generator capabilities, 2 input captures and 2 output compares. figure 1. st72101, st72213 and st72212 block diagram 8-bit core alu address and data bus oscin oscout reset port b timer a port a spi port c 8-bit adc 1) watchdog pb0 -> pb7 (8 bits) pc0 -> pc5 (6 bits) osc internal clock control ram (256 bytes) pa0 -> pa7 (8 bits) v ss v dd power supply timer b 2) 1) st72213 and st72212 only 2) st72212 only program (4 - 8k bytes) memory 4
5/84 st72101/st72212/st72213 1.2 pin description figure 2. st72212 pinout (so28) figure 3. st72213 pinout (so28) figure 4. st72101 pinout (so28) figure 5. st72212 pinout (sdip32) figure 6. st72213 pinout (sdip32) figure 7. st72101 pinout (sdip32) v dd v ss test/v pp 1) pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 pc0/icap1_b/ain0 pc1/ocmp1_b/ain1 pc2/clkout/ain2 reset oscin oscout ss/pb7 sck/pb6 miso/pb5 mosi/pb4 ocmp2_a/pb3 icap2_a/pb2 ocmp1_a/pb1 icap1_a/pb0 ain5/extclk_a/pc5 ain4/ocmp2_b/pc4 ain3/icap2_b/pc3 15 16 17 18 19 20 28 27 26 25 24 23 22 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1) v pp on eprom/otp only v dd v ss test/v pp 1) pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 pc0/ain0 pc1/ain1 pc2/clkout/ain2 reset oscin oscout ss/pb7 sck/pb6 miso/pb5 mosi/pb4 ocmp2_a/pb3 icap2_a/pb2 ocmp1_a/pb1 icap1_a/pb0 ain5/extclk_a/pc5 ain4/pc4 ain3/pc3 15 16 17 18 19 20 28 27 26 25 24 23 22 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1) v pp on eprom/otp only v dd v ss test/v pp 1) pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 pc0 pc1 pc2/clkout reset oscin oscout ss/pb7 sck/pb6 miso/pb5 mosi/pb4 ocmp2_a/pb3 icap2_a/pb2 ocmp1_a/pb1 icap1_a/pb0 extclk_a/pc5 pc4 pc3 15 16 17 18 19 20 28 27 26 25 24 23 22 21 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1) v pp on eprom/otp only reset oscin oscout ss/pb7 sck/pb6 miso/pb5 mosi/pb4 ocmp2_a/pb3 icap2_a/pb2 ocmp1_a/pb1 icap1_a/pb0 ain5/extclk_a/pc5 ain4/ocmp2_b/pc4 ain3/icap2_b/pc3 v dd v ss test/v pp 1) pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 pc0/icap1_b/ain0 pc1/ocmp1_b/ain1 pc2/clkout/ain2 nc nc nc nc 28 27 26 25 24 23 22 21 20 19 18 17 16 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 29 30 31 32 1) v pp on eprom/otp only reset oscin oscout ss/pb7 sck/pb6 miso/pb5 mosi/pb4 ocmp2_a/pb3 icap2_a/pb2 ocmp1_a/pb1 icap1_a/pb0 ain5/extclk_a/pc5 ain4/pc4 ain3/pc3 nc nc v dd v ss test/v pp 1) pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 pc0/ain0 pc1/ain1 pc2/clkout/ain2 nc nc 28 27 26 25 24 23 22 21 20 19 18 17 16 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 29 30 31 32 1) v pp on eprom/otp only v dd v ss test/v pp 1) pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 pc0 pc1 pc2/clkout reset oscin oscout ss/pb7 sck/pb6 miso/pb5 mosi/pb4 ocmp2_a/pb3 icap2_a/pb2 ocmp1_a/pb1 icap1_a/pb0 extclk_a/pc5 pc4 pc3 nc nc nc nc 28 27 26 25 24 23 22 21 20 19 18 17 16 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 29 30 31 32 1) v pp on eprom/otp only 5
6/84 st72101/st72212/st72213 table 1. st72212 pin configuration note 1 :v pp on eprom/otp only pin n sdip32 pin n so28 pin name type description remarks 1 1 reset i/o bidirectional. active low. top priority non maskable interrupt. 22oscin i input/output oscillator pin. these pins connect a parallel-resonant crystal, or an external source to the on-chip oscillator. 3 3 oscout o 4 4 pb7/ss i/o port b7 or spi slave select (active low) external interrupt: ei1 5 5 pb6/sck i/o port b6 or spi serial clock external interrupt: ei1 6 6 pb5/miso i/o port b5 or spi master in/ slave out data external interrupt: ei1 7 7 pb4/mosi i/o port b4 or spi master out / slave in data external interrupt: ei1 8 nc not connected 9 nc not connected 10 8 pb3/ocmp2_a i/o port b3 or timera output compare 2 external interrupt: ei1 11 9 pb2/icap2_a i/o port b2 or timera input capture 2 external interrupt: ei1 12 10 pb1/ocmp1_a i/o port b1 or timera output compare 1 external interrupt: ei1 13 11 pb0/icap1_a i/o port b0 or timera input capture 1 external interrupt: ei1 14 12 pc5/extclk_a/ain5 i/o port c5 or timera input clock or adc analog input 5 external interrupt: ei1 15 13 pc4/ocmp2_b/ain4 i/o port c4 ortimerb output compare 2or adcanalog input 4 external interrupt: ei1 16 14 pc3/icap2_b/ain3 i/o port c3 or timerb input capture 2 or adc analog input 3 external interrupt: ei1 17 15 pc2/clkout/ain2 i/o port c2 or internal clock frequency output or adc analog input 2. clockout is driven by bit 5 of the miscellaneous register. external interrupt: ei1 18 16 pc1/ocmp1_b/ain1 i/o port c1 ortimerb output compare 1or adcanalog input 1 external interrupt: ei1 19 17 pc0/icap1_b/ain0 i/o port c0 or timerb input capture 1 or adc analog input 0 external interrupt: ei1 20 18 pa7 i/o port a7, high sink external interrupt: ei0 21 19 pa6 i/o port a6, high sink external interrupt: ei0 22 20 pa5 i/o port a5, high sink external interrupt: ei0 23 21 pa4 i/o port a4, high sink external interrupt: ei0 24 nc not connected 25 nc not connected 26 22 pa3 i/o port a3, high sink external interrupt: ei0 27 23 pa2 i/o port a2, high sink external interrupt: ei0 28 24 pa1 i/o port a1, high sink external interrupt: ei0 29 25 pa0 i/o port a0, high sink external interrupt: ei0 30 26 test/v pp (1) i/s test mode pin (should be tied low in user mode). in the eprom program- ming mode, this pin acts as the programming voltage input v pp. 31 27 v ss s ground 32 28 v dd s main power supply 6
7/84 st72101/st72212/st72213 table 2. st72213 pin configuration note 1 :v pp on eprom/otp only pin n sdip32 pin n so28 pin name type description remarks 1 1 reset i/o bidirectional. active low. top prior ity non maskable interrup t. 2 2 oscin i input/output oscillator pin. these pins connect a parallel-resonant crystal, or an external source to the on-chip oscillator. 3 3 oscout o 4 4 pb7/ss i/o port b7 or spi slave select (active low) external interrupt: ei1 5 5 pb6/sck i/o port b6 or spi serial clock external interrupt: ei1 6 6 pb5/miso i/o port b5 or spi master in/ slave out data external interrupt: ei1 7 7 pb4/mosi i/o port b4 or spi master out / slave in data external interrupt: ei1 8 nc not connected 9 nc not connected 10 8 pb3/ocmp2_a i/o port b3 or timera output compare 2 external interrupt: ei1 11 9 pb2/icap2_a i/o port b2 or timera input capture 2 external interrupt: ei1 12 10 pb1/ocmp1_a i/o port b1 or timera output compare 1 external interrupt: ei1 13 11 pb0/icap1_a i/o port b0 or timera input capture 1 external interrupt: ei1 14 12 pc5/extclk_a/ain5 i/o port c5 or timera input clock or adc analog input 5 external interrupt: ei1 15 13 pc4/ain4 i/o port c4 or adc analog input 4 external interrupt: ei1 16 14 pc3/ain3 i/o port c3 or adc analog input 3 external interrupt: ei1 17 15 pc2/clkout/ain2 i/o port c2 or internal clock frequency output or adc analog input 2. clockout is driven by bit 5 of the miscellaneous register. external interrupt: ei1 18 16 pc1/ain1 i/o port c1 or adc analog input 1 external interrupt: ei1 19 17 pc0/ain0 i/o port c0 or adc analog input 0 external interrupt: ei1 20 18 pa7 i/o port a7, high sink external interrupt: ei0 21 19 pa6 i/o port a6, high sink external interrupt: ei0 22 20 pa5 i/o port a5, high sink external interrupt: ei0 23 21 pa4 i/o port a4, high sink external interrupt: ei0 24 nc not connected 25 nc not connected 26 22 pa3 i/o port a3, high sink external interrupt: ei0 27 23 pa2 i/o port a2, high sink external interrupt: ei0 28 24 pa1 i/o port a1, high sink external interrupt: ei0 29 25 pa0 i/o port a0, high sink external interrupt: ei0 30 26 test/v pp (1) i/s test mode pin (should be tied low in user mode). in the eprom pro- gramming mode, this pin acts as the programming voltage input v pp. 31 27 v ss s ground 32 28 v dd s main power supply 7
8/84 st72101/st72212/st72213 table 3. st72101 pin configuration pin n sdip32 pin n so28 pin name type description remarks 1 1 reset i/o bidirectional. active low. top priority non maskable interrupt. 2 2 oscin i input/output oscillator pin. these pins connect a parallel-resonant crystal, or an external source to the on-chip oscillator. 3 3 oscout o 4 4 pb7/ss i/o port b7 or spi slave select (active low) external interrupt: ei1 5 5 pb6/sck i/o port b6 or spi serial clock external interrupt: ei1 6 6 pb5/miso i/o port b5 or spi master in/ slave out data external interrupt: ei1 7 7 pb4/mosi i/o port b4 or spi master out / slave in data external interrupt: ei1 8 nc not connected 9 nc not connected 10 8 pb3/ocmp2_a i/o port b3 or timera output compare 2 external interrupt: ei1 11 9 pb2/icap2_a i/o port b2 or timera input capture 2 external interrupt: ei1 12 10 pb1/ocmp1_a i/o port b1 or timera output compare 1 external interrupt: ei1 13 11 pb0/icap1_a i/o port b0 or timera input capture 1 external interrupt: ei1 14 12 pc5/extclk_a i/o port c5 or timera input clock external interrupt: ei1 15 13 pc4 i/o port c4 external interrupt: ei1 16 14 pc3 i/o port c3 external interrupt: ei1 17 15 pc2/clkout i/o port c2 or internal clock frequency output. clockout is driven by mco bit of the miscellaneous register. external interrupt: ei1 18 16 pc1 i/o port c1 external interrupt: ei1 19 17 pc0 i/o port c0 external interrupt: ei1 20 18 pa7 i/o port a7, high sink external interrupt: ei0 21 19 pa6 i/o port a6, high sink external interrupt: ei0 22 20 pa5 i/o port a5, high sink external interrupt: ei0 23 21 pa4 i/o port a4, high sink external interrupt: ei0 24 nc not connected 25 nc not connected 26 22 pa3 i/o port a3, high sink external interrupt: ei0 27 23 pa2 i/o port a2, high sink external interrupt: ei0 28 24 pa1 i/o port a1, high sink external interrupt: ei0 29 25 pa0 i/o port a0, high sink external interrupt: ei0 30 26 test/v pp (1) i/s test mode pin (should be tied low in user mode). in the eprom programming mode, this pin acts as the programming voltage input v pp. 31 27 v ss s ground 32 28 v dd s main power supply note 1 :v pp on eprom/otp only. 8
9/84 st72101/st72212/st72213 1.3 external connections the following figure shows the recommended ex- ternal connections for the device. the v pp pin is only used for programming otp and eprom devices and must be tied to ground in user mode. the 10 nf and 0.1 m f decoupling capacitors on the power supply lines are a suggested emc per- formance/cost tradeoff. the external reset network is intended to protect the device against parasitic resets, especially in noisy environments. unused i/os should be tied high to avoid any un- necessary power consumption on floating lines. an alternative solution is to program the unused ports as inputs with pull-up. figure 8. recommended external connections v pp v dd v ss oscin oscout reset v dd 0.1 m f + see clocks section v dd 0.1 m f 0.1 m f external reset circuit or configure unused i/o ports unused i/o 10nf 4.7k 10k by software as input with pull-up v dd 9
10/84 st72101/st72212/st72213 1.4 memory map figure 9. memory map table 4. interrupt vector map vector address description remarks ffe0-ffe1h ffe2-ffe3h ffe4-ffe5h ffe6-ffe7h ffe8-ffe9h ffea-ffebh ffec-ffedh ffee-ffefh fff0-fff1h fff2-fff3h fff4-fff5h fff6-fff7h fff8-fff9h fffa-ff fbh fffc-fffdh fffe-ffffh not used not used not used not used not used not used not used timer b interrupt vector (st72212 only) not used timer a interrupt vector spi interrupt vector not used external interrupt vector ei1 external interrupt vector ei0 trap (software) interrupt vector reset vector internal interrupt internal interrupt internal interrupt external interrupt external interrupt cpu interrupt 0000h 8k bytes interrupt & reset vectors hw registers 017fh 0080h 007fh dfffh reserved (see table 5) e000h ffdfh ffe0h ffffh (see table 4) 4k bytes f000h 256 bytes ram short addressing ram (zero page) 16-bit addressing ram 0100h 0140h 017fh 0080h 00ffh 013fh 64 bytes stack or 16-bit addressing ram 0180h program memory program memory 10
11/84 st72101/st72212/st72213 table 5. hardware register memory map address block name register label register name reset status remarks 0000h 0001h 0002h port c pcdr pcddr pcor data register data direction register option register 00h 00h 00h r/w r/w r/w 0003h reserved area (1 byte) 0004h 0005h 0006h port b pbdr pbddr pbor data register data direction register option register 00h 00h 00h r/w r/w r/w 0007h reserved area (1 byte) 0008h 0009h 000ah port a padr paddr paor data register data direction register option register 00h 00h 00h r/w r/w r/w 000bh to 001fh reserved area (21 bytes) 0020h miscr miscellaneous register 00h r/w 0021h 0022h 0023h spi spidr spicr spisr data i/o register control register status register xxh 0xh 00h r/w r/w read only 0024h wdg wdgcr watchdog control register 7fh r/w 0025h to 0030h reserved area (12 bytes) 0031h 0032h 0033h 0034h-0035h 0036h-0037h 0038h-0039h 003ah-003bh 003ch-003dh 003eh-003fh timer a tacr2 tacr1 tasr taic1hr taic1lr taoc1hr taoc1lr tachr taclr taachr taaclr taic2hr taic2lr taoc2hr taoc2lr control register2 control register1 status register input capture1 high register input capture1 low register output compare1 high register output compare1 low register counter high register counter low register alternate counter high register alternate counter low register input capture2 high register input capture2 low register output compare2 high register output compare2 low register 00h 00h 00h xxh xxh 80h 00h ffh fch ffh fch xxh xxh 80h 00h r/w r/w read only read only read only r/w r/w read only read only read only read only read only read only r/w r/w 0040h reserved area (1 byte) 11
12/84 st72101/st72212/st72213 notes : 1. st72212 only, reserved area for other devices. 2. st72212 and st72213 only, reserved otherwise. 0041h 0042h 0043h 0044h-0045h 0046h-0047h 0048h-0049h 004ah-004bh 004ch-004dh 004eh-004fh timer b 1) tbcr2 tbcr1 tbsr tbic1hr tbic1lr tboc1hr tboc1lr tbchr tbclr tbachr tbaclr tbic2hr tbic2lr tboc2hr tboc2lr control register2 control register1 status register input capture1 high register input capture1 low register output compare1 high register output compare1 low register counter high register counter low register alternate counter high register alternate counter low register input capture2 high register input capture2 low register output compare2 high register output compare2 low register 00h 00h 00h xxh xxh 80h 00h ffh fch ffh fch xxh xxh 80h 00h r/w r/w read only read only read only r/w r/w read only read only read only read only read only read only r/w r/w 0050h to 006fh reserved area (32 bytes) 0070h 0071h adc 2) adcdr adccsr data register control/status register 00h 00h read only r/w 0072h to 007fh reserved area (14 bytes) address block name register label register name reset status remarks 12
13/84 st72101/st72212/st72213 2 central processing unit 2.1 introduction this cpu has a full 8-bit architecture and contains six internal registers allowing efficient 8-bit data manipulation. 2.2 main features n 63 basic instructions n fast 8-bit by 8-bit multiply n 17 main addressing modes (with indirect addressing mode) n two 8-bit index registers n 16-bit stack pointer n 8 mhz cpu internal frequency n low power modes n maskable hardware interrupts n non-maskable software interrupt 2.3 cpu registers the 6 cpu registers shown in figure 10 are not present in the memory mapping and are accessed by specific instructions. accumulator (a) the accumulator is an 8-bit general purpose reg- ister used to hold operands and the results of the arithmetic and logic calculations and to manipulate data. index registers (x and y) in indexed addressing modes, these 8-bit registers are used to create either effective addresses or temporary storage areas for data manipulation. (the cross-assembler generates a precede in- struction (pre) to indicate that the following in- struction refers to the y register.) the y register is not affected by the interrupt auto- matic procedures (not pushed to and popped from the stack). program counter (pc) the program counter is a 16-bit register containing the address of the next instruction to be executed by the cpu. it is made of two 8-bit registers pcl (program counter low which is the lsb) and pch (program counter high which is the msb). figure 10. cpu registers accumulator x index register y index register stack pointer conditio n code register program counter 70 1c 11hi nz reset value = reset vector @ fffeh-ffffh 70 70 70 0 7 15 8 pch pcl 15 87 0 reset value = stack higher address reset value = 1x 11x1xx reset value = xxh reset value = xxh reset value = xxh x = undefined value 13
14/84 st72101/st72212/st72213 central processing unit (cont'd) condition code register (cc) read/write reset value: 111x1xxx the 8-bit condition code register contains the in- terrupt mask and four flags representative of the result of the instruction just executed. this register can also be handled by the push and pop in- structions. these bits can be individually tested and/or con- trolled by specific instructions. bit 4 = h half carry . this bit is set by hardware when a carry occurs be- tween bits 3 and 4 of the alu during an add or adc instruction. it is reset by hardware during the same instructions. 0: no half carry has occurred. 1: a half carry has occurred. this bit is tested using the jrh or jrnh instruc- tion. the h bit is useful in bcd arithmetic subrou- tines. bit 3 = i interrupt mask . this bit is set by hardware when entering in inter- rupt or by software to disable all interrupts except the trap software interrupt. this bit is cleared by software. 0: interrupts are enabled. 1: interrupts are disabled. this bit is controlled by the rim, sim and iret in- structions and is tested by the jrm and jrnm in- structions. note: interrupts requested while i is set are latched and can be processed when i is cleared. by default an interrupt routine is not interruptable because the i bit is set by hardware when you en- ter it and reset by the iret instruction at the end of the interrupt routine. if the i bit is cleared by soft- ware in the interrupt routine, pending interrupts are serviced regardless of the priority level of the cur- rent interrupt routine. bit 2 = n negative . this bit is set and cleared by hardware. it is repre- sentative of the result sign of the last arithmetic, logical or data manipulation. it is a copy of the 7 th bit of the result. 0: the result of the last operation is positive or null. 1: the result of the last operation is negative (i.e. the most significant bit is a logic 1). this bit is accessed by the jrmi and jrpl instruc- tions. bit 1 = z zero . this bit is set and cleared by hardware. this bit in- dicates that the result of the last arithmetic, logical or data manipulation is zero. 0: the result of the last operation is different from zero. 1: the result of the last operation is zero. this bit is accessed by the jreq and jrne test instructions. bit 0 = c carry/borrow. this bit is set and cleared by hardware and soft- ware. it indicates an overflow or an underflow has occurred during the last arithmetic operation. 0: no overflow or underflow has occurred. 1: an overflow or underflow has occurred. this bit is driven by the scf and rcf instructions and tested by the jrc and jrnc instructions. it is also affected by the abit test and brancho, shift and rotate instructions. 70 111hinzc 14
15/84 st72101/st72212/st72213 central processing unit (cont'd) stack pointer (sp) read/write reset value: 01 7fh the stack pointer is a 16-bit register which is al- ways pointing to the next free location in the stack. it is then decremented after data has been pushed onto the stack and incremented before data is popped from the stack (see figure 11). since the stack is 64 bytes deep, the 10 most sig- nificant bits are forced by hardware. following an mcu reset, or after a reset stack pointer instruc- tion (rsp), the stack pointer contains its reset val- ue (the sp5 to sp0 bits are set) which is the stack higher address. the least significant byte of the stack pointer (called s) can be directly accessed by a ld in- struction. note: when the lower limit is exceeded, the stack pointer wraps around to the stack upper limit, with- out indicating the stack overflow. the previously stored information is then overwritten and there- fore lost. the stack also wraps in case of an under- flow. the stack is used to save the return address dur- ing a subroutine call and the cpu context during an interrupt. the user may also directly manipulate the stack by means of the push and pop instruc- tions. in the case of an interrupt, the pcl is stored at the first location pointed to by the sp. then the other registers are stored in the next locations as shown in figure 11. when an interrupt is received, the sp is decre- mented and the context is pushed on the stack. on return from interrupt, the sp is incremented and the context is popped from the stack. a subroutine call occupies two locations and an in- terrupt five locations in the stack area. figure 11. stack manipulation example 15 8 00000001 70 0 1 sp5 sp4 sp3 sp2 sp1 sp0 pch pcl sp pch pcl sp pcl pch x a cc pch pcl sp pcl pch x a cc pch pcl sp pcl pch x a cc pch pcl sp sp y call subroutine interrupt event push y pop y iret ret or rsp @ 017fh @ 0140h stack lower address = 0140h stack higher address = 017fh 15
16/84 st72101/st72212/st72213 3 clocks, reset, interrupts & power saving modes 3.1 clock system 3.1.1 general description the mcu accepts either a crystal or ceramic res- onator, or an external clock signal to drive the in- ternal oscillator. the internal clock (f cpu ) is de- rived from the external oscillator frequency (f osc ) . the external oscillator clock is first divided by 2, and division factor of 32 can be applied if slow mode is selected by setting the sms bit in the mis- cellaneous register. this reduces the frequency of the f cpu ; the clock signal is also routed to the on-chip peripherals. the internal oscillator is designed to operate with an at-cut parallel resonant quartz crystal resona- tor in the frequency range specified for f osc .the circuit shown in figure 13 is recommended when using a crystal, and table 6 lists the recommend- ed capacitance and feedback resistance values. the crystal and associated components should be mounted as close as possible to the input pins in order to minimize output distortion and start-up stabilisation time. use of an external cmos oscillator is recom- mended when crystals outside the specified fre- quency ranges are to be used. table 6. recommended values for 16 mhz crystal resonator (c 0 <7pf) c 0 : parasitic shunt capacitance of the quartz crys- tal. r smax : equivalent serial resistor of the crystal (up- er limit, see crystal specification). c oscout ,c oscin : maximum total capacitance on oscin and oscout, including the external ca- pacitance plus the parasitic capacitance of the board and the device. figure 12. external clock source connections figure 13. crystal/ceramic resonator figure 14. clock prescaler block diagram r smax 40 w 60 w 150 w c oscin 56pf 47pf 22pf c oscout 56pf 47pf 22pf oscin oscout external clock nc oscin oscout c oscin c oscout oscin oscout c oscin c oscout %2 % 16 f cpu to cpu and peripherals 16
17/84 st72101/st72212/st72213 3.2 reset 3.2.1 introduction there are three sources of reset: reset pin (external source) power-on reset (internal source) watchdog (internal source) the reset service routine vector is located at ad- dress fffeh-ffffh. 3.2.2 external reset the reset pin is both an input and an open-drain output with integrated pull-up resistor. when one of the internal reset sources is active, the reset pin is driven low , for a duration of t reset, to reset the whole application. 3.2.3 reset operation the duration of the reset state is a minimum of 4096 internal cpu clock cycles. during the reset state, all i/os take their reset value. a reset signal originating from an external source must have a duration of at least t pulse in order to be recognised. this detection is asynchronous and therefore the mcu can enter reset state even in halt mode. at the end of the reset cycle, the mcu may be held in the reset state by an external reset sig- nal. the reset pin may thus be used to ensure v dd has risen to a point where the mcu can oper- ate correctly before the user program is run. fol- lowing a reset event, or after exiting halt mode, a 4096 cpu clock cycle delay period is initiated in order to allow the oscillator to stabilise and to en- sure that recovery has taken place from the reset state. in the high state, the reset pin is connected in- ternally to a pull-up resistor (r on ). this resistor can be pulled low by external circuitry to reset the device. the reset pin is an asynchronous signal which plays a major role in ems performance. in a noisy environment, it is recommended to use the exter- nal connections shown in figure 8. 3.2.4 power-on reset this circuit detects the ramping up of v dd , and generates a pulse that is used to reset the applica- tion (at approximately v dd = 2v). power-on reset is designed exclusively to cope with power-up conditions, and should not be used in order to attempt to detect a drop in the power supply voltage. caution : to re-initialize the power-on reset, the power supply must fall below approximately 0.8v (vtn), prior to rising above 2v. if this condition is not respected, on subsequent power-up the reset pulse may not be generated. an external reset pulse may be required to correctly reactivate the circuit. figure 15. reset block diagram internal reset watchdog reset oscillator signal counter reset to st7 reset power-on reset v dd r on 17
18/84 st72101/st72212/st72213 3.3 interrupts the st7 core may be interrupted by one of two dif- ferent methods: maskable hardware interrupts as listed in the interrupt mapping table and a non- maskable software interrupt (trap). the interrupt processing flowchart is shown in figure 16. the maskable interrupts must be enabled clearing the i bit in order to be serviced. however, disabled interrupts may be latched and processed when they are enabled (see external interrupts subsec- tion). when an interrupt has to be serviced: normal processing is suspended at the end of the current instruction execution. the pc, x, a and cc registers are saved onto the stack. the i bit of the cc register is set to prevent addi- tional interrupts. the pc is then loaded with the interrupt vector of the interrupt to service and the first instruction of the interrupt service routine is fetched (refer to the interrupt mapping table for vector address- es). the interrupt service routine should finish with the iret instruction which causes the contents of the saved registers to be recovered from the stack. note: as a consequence of the iret instruction, the i bit will be cleared and the main program will resume. priority management by default, a servicing interrupt can not be inter- rupted because the i bit is set by hardware enter- ing in interrupt routine. in the case several interrupts are simultaneously pending, an hardware priority defines which one will be serviced first (see the interrupt mapping ta- ble). non maskable software interrupts this interrupt is entered when the trap instruc- tion is executed regardless of the state of the i bit. it will be serviced according to the flowchart on figure 16. interrupts and low power mode all interrupts allow the processor to leave the wait low power mode. only external and specific men- tioned interrupts allow the processor to leave the halt low power mode (refer to the aexit from halta column in the interrupt mapping table). external interrupts external interrupt vectors can be loaded in the pc register if the corresponding external interrupt oc- curred and if the i bit is cleared. these interrupts allow the processor to leave the halt low power mode. the external interrupt polarity is selected through the miscellaneous register or interrupt register (if available). external interrupt triggered on edge will be latched and the interrupt request automatically cleared upon entering the interrupt service routine. if several input pins, connected to the same inter- rupt vector, are configured as interrupts, their sig- nals are logically anded before entering the edge/ level detection block. warning: the type of sensitivity defined in the miscellaneous or interrupt register (if available) applies to the ei source. in case of an anded source (as described on the i/o ports section), a low level on an i/o pin configured as input with in- terrupt, masks the interrupt request even in case of rising-edge sensitivity. peripheral interrupts different peripheral interrupt flags in the status register are able to cause an interrupt when they are active if both: the i bit of the cc register is cleared. the corresponding enable bit is set in the control register. if any of these two conditions is false, the interrupt is latched and thus remains pending. clearing an interrupt request is done by: writing a0o to the corresponding bit in the status register or an access to the status register while the flag is set followed by a read or write of an associated register. note : the clearing sequence resets the internal latch. a pending interrupt (i.e. waiting for being en- abled) will therefore be lost if the clear sequence is executed. 18
19/84 st72101/st72212/st72213 interrupts (cont'd) figure 16. interrupt processing flowchart bit i set y n iret y n from reset load pc from interrupt vecto r stack pc, x, a, cc set i bit fetch next instr uction execu te instruction this clears i bit by default restore pc, x, a, cc from stack bit i set y n 19
20/84 st72101/st72212/st72213 table 7. interrupt mapping note 1 : timer b is available on st72212 only. source block description register label flag exit from halt vector address priority order reset reset n/a n/a yes fffeh-fff fh trap software n/a n/a no fffch-fff dh ei0 external interrupt pa0:pa7 n/a n/a yes fffah-fffbh ei1 external interrupt pb0:pb7, pc0:pc5 n/a n/a yes fff8h-fff 9h not used fff6h-fff 7h spi transfer complete spisr spif no fff4h-fff 5h mode fault modf timer a input capture 1 tasr icf1_a no fff2h-fff 3h output compare 1 ocf1_a input capture 2 icf2_a output compare 2 ocf2_a timer overflow tof_a not used fff0h-fff 1h timer b 1) input capture 1 tbsr icf1_b no ffeeh-ffefh output compare 1 ocf1_b input capture 2 icf2_b output compare 2 ocf2_b timer overflow tof_b not used ffech-ffedh ffeah-ffebh ffe8h-ffe9h ffe6h-ffe7h ffe4h-ffe5h ffe2h-ffe3h ffe0h-ffe1h highest priority priority lowest 20
21/84 st72101/st72212/st72213 3.4 power saving modes 3.4.1 introduction there are three power saving modes. slow mode is selected by setting the relevant bits in the mis- cellaneous register. wait and halt modes may be entered using the wfi and halt instructions. 3.4.2 slow mode in slow mode, the oscillator frequency can be di- vided by a value defined in the miscellaneous register. the cpu and peripherals are clocked at this lower frequency. slow mode is used to reduce power consumption, and enables the user to adapt clock frequency to available supply voltage. 3.4.3 wait mode wait mode places the mcu in a low power con- sumption mode by stopping the cpu. all peripher- als remain active. during wait mode, the i bit (cc register) is cleared, so as to enable all interrupts. all other registers and memory remain unchanged. the mcu will remain in wait mode until an inter- rupt or reset occurs, whereupon the program counter branches to the starting address of the in- terrupt or reset service routine. the mcu will remain in wait mode until a reset or an interrupt occurs, causing it to wake up. refer to figure 17 below. figure 17. wait flow chart wfi instruction reset interrupt y n n y cpu clock oscillator periph. clock i-bit on on cleared off note: before servicing an interrupt, the cc register is pushed on the stack. the i-bit is set during the inter- rupt routine and cleared when the cc register is popped. 4096 cpu clock fetch reset vector or service interrupt cycles delay cpu clock oscillator periph. clock i-bit on on set on cpu clock oscillator periph. clock i-bit on on set on 21
22/84 st72101/st72212/st72213 power saving modes (cont'd) 3.4.4 halt mode the halt mode is the mcu lowest power con- sumption mode. the halt mode is entered by exe- cuting the halt instruction. the internal oscillator is then turned off, causing all internal processing to be stopped, including the operation of the on-chip peripherals. the halt mode cannot be used when the watchdog is enabled, if the halt instruction is executed while the watchdog system is enabled, a watchdog reset is generated thus resetting the en- tire mcu. when entering halt mode, the i bit in the cc reg- ister is cleared so as to enable external interrupts. if an interrupt occurs, the cpu becomes active. the mcu can exit the halt mode upon reception of an interrupt or a reset. refer to the interrupt map- ping table. the oscillator is then turned on and a stabilization time is provided before releasing cpu operation. the stabilization time is 4096 cpu clock cycles. after the start up delay, the cpu continues oper- ation by servicing the interrupt which wakes it up or by fetching the reset vector if a reset wakes it up. figure 18. halt flow chart n n external interrupt 1) reset halt instruction 4096 cpu clock fetch reset vector or service interrupt cycles delay cpu clock oscillator periph. clock 2) i-bit on off set on cpu clock oscillator periph. clock i-bit off off cleared off y y wdg enabled? n y reset watchdog 1) or some specific interrupts note: before servicing an interrupt, the cc register is pushed on the stack. the i-bit is set during the inter- rupt routine and cleared when the cc register is popped. cpu clock oscillator periph. clock i-bit on on set on 2) if reset periph. clock = on ; if interrupt periph. clock = off 22
23/84 st72101/st72212/st72213 3.5 miscellaneous register the miscellaneous register allows to select the slow operating mode, the polarity of external in- terrupt requests and to output the internal clock. register address: 0020h e read/ write reset value: 0000 0000 (00h) bit 7:6 = pei[3:2] external interrupt ei1 polarity option . these bits are set and cleared by software. they determine which event on ei1 causes the exter- nal interrupt according to table 8. table 8. ei1 external interrupt polarity options note: any modification of one of these two bits re- sets the interrupt request related to this interrupt vector. bit 5 = mco main clock out this bit is set and cleared by software. when set, it enables the output of the internal clock on the pc2 i/o port. 0 - pc2 is a general purpose i/o port. 1 - mco alternate function (f cpu is output on pc2 pin). bit 4:3 = pei[1:0] external interrupt ei0 polarity option . these bits are set and cleared by software. they determine which event on ei0 causes the exter- nal interrupt according to table 9. table 9. ei0 external interrupt polarity options note: any modification of one of these two bits re- sets the interrupt request related to this interrupt vector. bit 1:2 = unused, always read at 0. warning: software must write 1 to these bits for compatibility with future products. bit 0 = sms slow mode select this bit is set and cleared by software. 0- normal mode - f cpu = oscillator frequency / 2 (reset state) 1- slow mode - f cpu = oscillator frequency /32 70 pei3 pei2 mco pei1 pei0 - - sms mode pei3 pei2 falling edge and low level (reset state) 00 falling edge only 1 0 rising edge only 0 1 rising and falling edge 1 1 mode pei1 pei0 falling edge and low level (reset state) 00 falling edge only 1 0 rising edge only 0 1 rising and falling edge 1 1 23
24/84 st72101/st72212/st72213 4 on-chip peripherals 4.1 i/o ports 4.1.1 introduction the i/o ports offer different functional modes: transfer of data through digital inputs and outputs and for specific pins: analog signal input (adc) alternate signal input/output for the on-chip pe- ripherals. external interrupt generation an i/o port is composed of up to 8 pins. each pin can be programmed independently as digital input (with or without interrupt generation) or digital out- put. 4.1.2 functional description each port is associated to 2 main registers: data register (dr) data direction register (ddr) and some of them to an optional register: option register (or) each i/o pin may be programmed using the corre- sponding register bits in ddr and or registers: bit x corresponding to pin x of the port. the same cor- respondence is used for the dr register. the following description takes into account the or register, for specific ports which do not provide this register refer to the i/o port implementation section 4.1.3. the generic i/o block diagram is shown on figure 20. 4.1.2.1 input modes the input configuration is selected by clearing the corresponding ddr register bit. in this case, reading the dr register returns the digital value applied to the external i/o pin. different input modes can be selected by software through the or register. notes : 1. all the inputs are triggered by a schmitt trigger. 2. when switching from input mode to output mode, the dr register should be written first to output the correct value as soon as the port is con- figured as an output. interrupt function when an i/o is configured in input with interrupt, an event on this i/o can generate an external in- terrupt request to the cpu. the interrupt polarity is given independently according to the description mentioned in the miscellaneous register or in the interrupt register (where available). each pin can independently generate an interrupt request. each external interrupt vector is linked to a dedi- cated group of i/o port pins (see interrupts sec- tion). if several input pins are configured as inputs to the same interrupt vector, their signals are logi- cally anded before entering the edge/level detec- tion block. for this reason if one of the interrupt pins is tied low, it masks the other ones. 4.1.2.2 output mode the pin is configured in output mode by setting the corresponding ddr register bit. in this mode, writing a0o or a1o to the dr register applies this digital value to the i/o pin through the latch. then reading the dr register returns the previously stored value. note : in this mode, the interrupt function is disa- bled. 4.1.2.3 digital alternate function when an on-chip peripheral is configured to use a pin, the alternate function is automatically select- ed. this alternate function takes priority over standard i/o programming. when the signal is coming from an on-chip peripheral, the i/o pin is automatically configured in output mode (push-pull or open drain according to the peripheral). when the signal is going to an on-chip peripheral, the i/o pin has to be configured in input mode. in this case, the pin's state is also digitally readable by addressing the dr register. notes: 1. input pull-up configuration can cause an unex- pected value at the input of the alternate peripher- al input. 2. when the on-chip peripheral uses a pin as input and output, this pin must be configured as an input (ddr = 0). warning : the alternate function must not be acti- vated as long as the pin is configured as input with interrupt, in order to avoid generating spurious in- terrupts. 24
25/84 st72101/st72212/st72213 i/o ports (cont'd) 4.1.2.4 analog alternate function when the pin is used as an adc input the i/o must be configured as input, floating. the analog multi- plexer (controlled by the adc registers) switches the analog voltage present on the selected pin to the common analog rail which is connected to the adc input. it is recommended not to change the voltage level or loading on any port pin while conversion is in progress. furthermore it is recommended not to have clocking pins located close to a selected an- alog pin. warning : the analog input voltage level must be within the limits stated in the absolute maximum ratings. 4.1.3 i/o port implementation the hardware implementation on each i/o port de- pends on the settings in the ddr and or registers and specific feature of the i/o port such as adc in- put (see figure 20) or true open drain. switching these i/o ports from one state to another should be done in a sequence that prevents unwanted side effects. recommended safe transitions are il- lustrated in figure 19. other transitions are poten- tially risky and should be avoided, since they are likely to present unwanted side-effects such as spurious interrupt generation. figure 19. recommended i/o state transition diagram with interrupt input output no interrupt input push-pull open-drain output 25
26/84 st72101/st72212/st72213 i/o ports (cont'd) figure 20 . i/o block diagram table 10. port mode configuration legend : 0 - present, not activated 1 - present and activated notes : no or register on some ports (see register map). adc switch on ports with analog alternate functions. dr ddr latch latch data bus dr sel ddr sel v dd pad analog switch analog enable (adc) m u x alternate alternate alternate enable common analog rail alternate m u x alternate input pull-up output p-buffer (s ee t able b elow ) n-buffer 1 0 1 0 or latch or sel from other bits external pull-up conditio n enable enable gnd (s ee t able below ) (s ee n ote below ) cmos schmitt trigger source (eix) interrupt polarity sel gnd v dd d iode (s ee t able below ) configu ration mode pull-up p-buffer v dd diode floating 0 0 1 pull-up 1 0 1 push-pull 0 1 1 true open drain not present not present not present in otp and eprom devices open drain (logic level) 0 0 1 26
27/84 st72101/st72212/st72213 table 11. port configuration *reset state port pin name input (ddr = 0) output (ddr = 1) or = 0 or = 1 or = 0 or = 1 port a pa0:pa7 floating* floating with interrupt true open drain, high sink capability reserved port b pb0:pb7 floating* pull-up with interrupt open drain (logic level) push-pull port c pc0:pc5 floating* pull-up with interrupt open drain (logic level) push-pull 27
28/84 st72101/st72212/st72213 i/o ports (cont'd) 4.1.4 register description 4.1.4.1 data registers port a data register (padr) port b data register (pbdr) port c data register (pcdr) read/write reset value: 0000 0000 (00h) bit 7:0 = d7-d0 data register 8 bits. the dr register has a specific behaviour accord- ing to the selected input/output configuration. writ- ing the dr register is always taken in account even if the pin is configured as an input. reading the dr register returns either the dr register latch content (pin configured as output) or the digital val- ue applied to the i/o pin (pin configured as input). 4.1.4.2 data direction registers port a data direction register (paddr) port b data direction register (pbddr) port c data direction register (pcddr) read/write reset value: 0000 0000 (00h) (input mode) bit 7:0 = dd7-dd0 data direction register 8 bits. the ddr register gives the input/output direction configuration of the pins. each bit is set and cleared by software. 0: input mode 1: output mode 4.1.4.3 option registers port a option register (paor) port b option register (pbor) port c option register (pcor) read/write reset value: 0000 0000 (00h) (no interrupt) bit 7:0 = o7-o0 option register 8 bits. for specific i/o pins, this register is not implement- ed. in this case the ddr register is enough to se- lect the i/o pin configuration. the or register allow to distinguish: in input mode if the interrupt capability or the floating configura- tion is selected, in output mode if the push-pull or open drain configuration is selected. each bit is set and cleared by software. input mode: 0: floating input 1: input interrupt with or without pull-up output mode (only for pb0:pb7, pc0:pc5): 0: output open drain (with p-buffer inactivated) 1: output push-pull output mode (only for pa0:pa7): 0: output open drain 1: reserved 70 d7 d6 d5 d4 d3 d2 d1 d0 70 dd7 dd6 dd5 dd4 dd3 dd2 dd1 dd0 70 o7 o6 o5 o4 o3 o2 o1 o0 28
29/84 st72101/st72212/st72213 i/o ports (cont'd) table 12. i/o port register map and reset values address (hex.) register label 76543210 0000h pcdr reset value d7 0 d6 0 d5 0 d4 0 d37 0 d2 0 d1 0 d0 0 0001h pcddr reset value dd7 0 dd6 0 dd5 0 dd4 0 dd3 0 dd2 0 dd1 0 dd0 0 0002h pcor reset value o7 0 o6 0 o5 0 o4 0 o3 0 o2 0 o1 0 o0 0 0004h pbdr reset value d7 0 d6 0 d5 0 d4 0 d37 0 d2 0 d1 0 d0 0 0005h pbddr reset value dd7 0 dd6 0 dd5 0 dd4 0 dd3 0 dd2 0 dd1 0 dd0 0 0006h pbor reset value o7 0 o6 0 o5 0 o4 0 o3 0 o2 0 o1 0 o0 0 0008h padr reset value d7 0 d6 0 d5 0 d4 0 d37 0 d2 0 d1 0 d0 0 0009h paddr reset value dd7 0 dd6 0 dd5 0 dd4 0 dd3 0 dd2 0 dd1 0 dd0 0 000ah paor reset value o7 0 o6 0 o5 0 o4 0 o3 0 o2 0 o1 0 o0 0 29
30/84 st72101/st72212/st72213 4.2 watchdog timer (wdg) 4.2.1 introduction the watchdog timer is used to detect the occur- rence of a software fault, usually generated by ex- ternal interference or by unforeseen logical condi- tions, which causes the application program to abandon its normal sequence. the watchdog cir- cuit generates an mcu reset on expiry of a pro- grammed time period, unless the program refresh- es the counter's contents before the t6 bit be- comes cleared. 4.2.2 main features n programmable timer (64 increments of 12288 cpu cycles) n programmable reset n reset (if watchdog activated) after a halt instruction or when the t6 bit reaches zero figure 21. watchdog block diagram reset wdga 7-bit downcounter f cpu t6 t0 clock divider watchdog control register (cr) 12288 t1 t2 t3 t4 t5 30
31/84 st72101/st72212/st72213 watchdog timer (cont'd) 4.2.3 functional description the counter value stored in the cr register (bits t6:t0), is decremented every 12,288 machine cy- cles, and the length of the timeout period can be programmed by the user in 64 increments. if the watchdog is activated (the wdga bit is set) and when the 7-bit timer (bits t6:t0) rolls over from 40h to 3fh (t6 becomes cleared), it initiates a reset cycle pulling low the reset pin for typically 500ns. the application program must write in the cr reg- ister at regular intervals during normal operation to prevent an mcu reset. the value to be stored in the cr register must be between ffh and c0h (see table 13): the wdga bit is set (watchdog enabled) the t6 bit is set to prevent generating an imme- diate reset the t5:t0 bits contain the number of increments which represents the time delay before the watchdog produces a reset. table 13. watchdog timing (f cpu = 8 mhz) notes: following a reset, the watchdog is disa- bled. once activated it cannot be disabled, except by a reset. the t6 bit can be used to generate a software re- set (the wdga bit is set and the t6 bit is cleared). if the watchdog is activated, the halt instruction will generate a reset. 4.2.4 low power modes 4.2.5 interrupts none. 4.2.6 register description control register (cr) read/write reset value: 0111 1111 (7fh) bit 7 = wdga activation bit . this bit is set by software and only cleared by hardware after a reset. when wdga = 1, the watchdog can generate a reset. 0: watchdog disabled 1: watchdog enabled bit 6:0 = t[6:0] 7-bit timer (msb to lsb). these bits contain the decremented value. a reset is produced when it rolls over from 40h to 3fh (t6 becomes cleared). table 14. watchdog timer register map and reset values cr register initial value wdg timeout period (ms) max ffh 98.304 min c0h 1.536 mode description wait no effect on watchdog. halt immediate reset generation as soon as the halt instruction is executed if the watchdog is activated (wdga bit is set). 70 wdga t6 t5 t4 t3 t2 t1 t0 address (hex.) register label 765 4 3210 0024h wdgcr reset value wdga 0 t6 1 t5 1 t4 1 t3 1 t2 1 t1 1 t0 1 31
32/84 st72101/st72212/st72213 4.3 16-bit timer 4.3.1 introduction the timer consists of a 16-bit free-running counter driven by a programmable prescaler. it may be used for a variety of purposes, including pulse length measurement of up to two input sig- nals ( input capture ) or generation of up to two out- put waveforms ( output compare and pwm ). pulse lengths and waveform periods can be mod- ulated from a few microseconds to several milli- seconds using the timer prescaler and the cpu clock prescaler. 4.3.2 main features n programmable prescaler: f cpu divided by 2, 4 or 8. n overflow status flag and maskable interrupt n external clock input (must be at least 4 times slower than the cpu clock speed) with the choice of active edge n output compare functions with 2 dedicated 16-bit registers 2 dedicated programmable signals 2 dedicated status flags 1 dedicated maskable interrupt n input capture functions with 2 dedicated 16-bit registers 2 dedicated active edge selection signals 2 dedicated status flags 1 dedicated maskable interrupt n pulse width modulation mode (pwm) n one pulse mode n 5 alternate functions on i/o ports (icap1, icap2, ocmp1, ocmp2, extclk)* the block diagram is shown in figure 22. *note: some external pins are not available on all devices. refer to the device pin out description. when reading an input signal which is not availa- ble on an external pin, the value will always be `1'. 4.3.3 functional description 4.3.3.1 counter the principal block of the programmable timer is a 16-bit free running increasing counter and its as- sociated 16-bit registers: counter registers counter high register (chr) is the most sig- nificant byte (msb). counter low register (clr) is the least sig- nificant byte (lsb). alternate counter registers alternate counter high register (achr) is the most significant byte (msb). alternate counter low register (aclr) is the least significant byte (lsb). these two read-only 16-bit registers contain the same value but with the difference that reading the aclr register does not clear the tof bit (overflow flag), (see note at the end of paragraph titled 16-bit read sequence). writing in the clr register or aclr register resets the free running counter to the fffch value. the timer clock depends on the clock control bits of the cr2 register, as illustrated in table 15. the value in the counter register repeats every 131.072, 262.144 or 524.288 internal processor- clock cycles depending on the cc1 and cc0 bits. 32
33/84 st72101/st72212/st72213 16-bit timer (cont'd) figure 22. timer block diagram mcu-peripheral interface counter alternate register output compare register output compare edge detect overflow detect circuit 1/2 1/4 1/8 8-bit buffer st7 internal bus latch1 ocmp1 icap1 extclk f cpu timer interrupt icf2 icf1 0 0 0 ocf2 ocf1 tof pwm oc1e exedg iedg2 cc0 cc1 oc2e opm folv2 icie olvl1 iedg1 olvl2 folv1 ocie toie icap2 latch2 ocmp2 8 8 8 low 16 8 high 16 16 16 16 cr1 cr2 sr 6 16 888 8 88 high low high high high low low low exedg timer internal bus circuit1 edge detect circuit2 circuit 1 output compare register 2 input capture register 1 input capture register 2 cc1 cc0 16 bit free running counter 33
34/84 st72101/st72212/st72213 16-bit timer (cont'd) 16-bit read sequence: (from either the counter register or the alternate counter register). the user must read the msb first, then the lsb value is buffered automatically. this buffered value remains unchanged until the 16-bit read sequence is completed, even if the user reads the msb several times. after a complete reading sequence, if only the clr register or aclr register are read, they re- turn the lsb of the count value at the time of the read. whatever the timer mode used (input capture, out- put compare, one pulse mode or pwm mode) an overflow occurs when the counter rolls over from ffffh to 0000h then: the tof bit of the sr register is set. a timer interrupt is generated if: toie bit of the cr1 register is set and i bit of the cc register is cleared. if one of these conditions is false, the interrupt re- mains pending to be issued as soon as they are both true. clearing the overflow interrupt request is done in two steps: 1. reading the sr register while the tof bit is set. 2. an access (read or write) to the clr register. notes: the tof bit is not cleared by accesses to aclr register. this feature allows simultaneous use of the overflow function and reads of the free running counter at random times (for example, to measure elapsed time) without the risk of clearing the tof bit erroneously. the timer is not affected by wait mode. in halt mode, the counter stops counting until the mode is exited. counting then resumes from the previous count (mcu awakened by an interrupt) or from the reset count (mcu awakened by a reset). 4.3.3.2 external clock the external clock (where available) is selected if cc0=1 and cc1=1 in cr2 register. the status of the exedg bit determines the type of level transition on the external clock pin ext- clk that will trigger the free running counter. the counter is synchronised with the falling edge of the internal cpu clock. at least four falling edges of the cpu clock must occur between two consecutive active edges of the external clock; thus the external clock frequen- cy must be less than a quarter of the cpu clock frequency. lsb is buffered read msb at t0 read lsb returns the buffered lsb value at t0 at t0 + d t other instructions beginning of the sequence sequence completed 34
35/84 st72101/st72212/st72213 16-bit timer (cont'd) figure 23. counter timing diagram, internal clock divided by 2 figure 24. counter timing diagram, internal clock divided by 4 figure 25. counter timing diagram, internal clock divided by 8 cpu clock fffd fffe ffff 0000 0001 0002 0003 internal reset timer clock counter register overflow flag tof fffc fffd 0000 0001 cpu clock internal reset timer clock counter register overflow flag tof cpu clock internal reset timer clock counter register overflow flag tof fffc fffd 0000 35
36/84 st72101/st72212/st72213 16-bit timer (cont'd) 4.3.3.3 input capture in this section, the index, i , may be 1 or 2. the two input capture 16-bit registers (ic1r and ic2r) are used to latch the value of the free run- ning counter after a transition detected by the icap i pin (see figure 5). ic i register is a read-only register. the active transition is software programmable through the iedg i bit of the control register (cr i ). timing resolution is one count of the free running counter: ( f cpu /(cc1.cc0) ). procedure: to use the input capture function select the follow- ing in the cr2 register: select the timer clock (cc1-cc0) (see table 15). select the edge of the active transition on the icap2 pin with the iedg2 bit (the icap2 pin must be configured as floating input). and select the following in the cr1 register: set the icie bit to generate an interrupt after an input capture coming from both the icap1 pin or the icap2 pin select the edge of the active transition on the icap1 pin with the iedg1 bit (the icap1pin must be configured as floating input). when an input capture occurs: icf i bit is set. the ic i r register contains the value of the free running counter on the active transition on the icap i pin (see figure 27). a timer interrupt is generated if the icie bit is set and the i bit is cleared in the cc register. other- wise, the interrupt remains pending until both conditions become true. clearing the input capture interrupt request is done in two steps: 1. reading the sr register while the icf i bit is set. 2. an access (read or write) to the ic i lr register. notes: 1. after reading the ic i hr register, transfer of input capture data is inhibited until the ic i lr register is also read. 2. the ic i r register always contains the free run- ning counter value which corresponds to the most recent input capture. 3. the 2 input capture functions can be used together even if the timer also uses the output compare mode. 4. in one pulse mode and pwm mode only the input capture 2 can be used. 5. the alternate inputs (icap1 & icap2) are always directly connected to the timer. so any transitions on these pins activate the input cap- ture process. 6. moreover if one of the icap i pin is configured as an input and the second one as an output, an interrupt can be generated if the user toggle the output pin and if the icie bit is set. 7. the tof bit can be used with interrupt in order to measure event that go beyond the timer range (ffffh). ms byte ls byte icir ic i hr ic i lr 36
37/84 st72101/st72212/st72213 16-bit timer (cont'd) figure 26. input capture block diagram figure 27. input capture timing diagram icie cc0 cc1 16-bit free running counter iedg1 (control register 1) cr1 (control register 2) cr2 icf2 icf1 0 0 0 (status register) sr iedg2 icap1 icap2 edge detect circuit2 16-bit ic1r register ic2r register edge detect circuit1 pin pin ff01 ff02 ff03 ff03 timer clock counter register icapi pin icapi flag icapi register note: a ctive edge is rising edge. 37
38/84 st72101/st72212/st72213 16-bit timer (cont'd) 4.3.3.4 output compare in this section, the index, i , may be 1 or 2. this function can be used to control an output waveform or indicating when a period of time has elapsed. when a match is found between the output com- pare register and the free running counter, the out- put compare function: assigns pins with a programmable value if the ocie bit is set sets a flag in the status register generates an interrupt if enabled two 16-bit registers output compare register 1 (oc1r) and output compare register 2 (oc2r) contain the value to be compared to the free run- ning counter each timer clock cycle. these registers are readable and writable and are not affected by the timer hardware. a reset event changes the oc i r value to 8000h. timing resolution is one count of the free running counter: ( f cpu/(cc1.cc0) ). procedure: to use the output compare function, select the fol- lowing in the cr2 register: set the oc i e bit if an output is needed then the ocmp i pin is dedicated to the output compare i function. select the timer clock (cc1-cc0) (see table 15). and select the following in the cr1 register: select the olvl i bit to applied to the ocmp i pins after the match occurs. set the ocie bit to generate an interrupt if it is needed. when a match is found: ocf i bit is set. the ocmp i pin takes olvl i bit value (ocmp i pin latch is forced low during reset and stays low until valid compares change it to a high level). a timer interrupt is generated if the ocie bit is set in the cr2 register and the i bit is cleared in the cc register (cc). the oc i r register value required for a specific tim- ing application can be calculated using the follow- ing formula: where: d t = desired output compare period (in sec- onds) f cpu = internal clock frequency presc = timer prescaler factor (2, 4 or 8 de- pending on cc1-cc0 bits, see table 15) clearing the output compare interrupt request is done by: 1. reading the sr register while the ocf i bit is set. 2. an access (read or write) to the oc i lr register. the following procedure is recommended to pre- vent the ocf i bit from being set between the time it is read and the write to the oc i r register: write to the oc i hr register (further compares are inhibited). read the sr register (first step of the clearance of the ocf i bit, which may be already set). write to the oc i lr register (enables the output compare function and clears the ocf i bit). notes: 1. after a processor write cycle to the oc i hr reg- ister, the output compare function is inhibited until the oc i lr register is also written. 2. if the oc i e bit is not set, the ocmp i pin is a general i/o port and the olvl i bit will not appear when a match is found but an interrupt could be generated if the ocie bit is set. 3. when the clock is divided by 2, ocf i and ocmp i are set while the counter value equals the oc i r register value (see figure 29, on page 39). this behaviour is the same in opm or pwm mode. when the clock is divided by 4, 8 or in external clock mode, ocf i and ocmp i are set while the counter value equals the oc i r register value plus 1 (see figure 30, on page 39). 4. the output compare functions can be used both for generating external events on the ocmp i pins even if the input capture mode is also used. 5. the value in the 16-bit oc i r register and the olv i bit should be changed after each suc- cessful comparison in order to control an output waveform or establish a new elapsed timeout. ms byte ls byte oc i roc i hr oc i lr d oc i r= d t * f cpu presc 38
39/84 st72101/st72212/st72213 16-bit timer (cont'd) figure 28. output compare block diagram figure 29. output compare timing diagram, internal clock divided by 2 figure 30. output compare timing diagram, internal clock divided by 4 output compare 16-bit circuit oc1r register 16 bit free running counter oc1e cc0 cc1 oc2e olvl1 olvl2 ocie (control register 1) cr1 (control register 2) cr2 0 0 0 ocf2 ocf1 (status register) sr 16-bit 16-bit ocmp1 ocmp2 latch 1 latch 2 oc2r register pin pin internal cpu clock timer clock counter output compare register output compare flag (ocfi) ocmpi pin (olvli=1) 2ed3 2ed0 2ed1 2ed2 2ed3 2ed4 2ecf internal cpu clock timer clock counter output compare register compare register latch ocfi and ocmpi pin (olvli=1) 2ed3 2ed0 2ed1 2ed2 2ed3 2ed4 2ecf 39
40/84 st72101/st72212/st72213 16-bit timer (cont'd) 4.3.3.5 forced compare in this section i may represent 1 or 2. the following bits of the cr1 register are used: when the folv i bit is set by software, the olvl i bit is copied to the ocmp i pin. the olv i bit has to be toggled in order to toggle the ocmp i pin when it is enabled (oc i e bit=1). the ocf i bit is then not set by hardware, and thus no interrupt request is generated. folvl i bits have no effect in both one pulse mode and pwm mode. 4.3.3.6 one pulse mode one pulse mode enables the generation of a pulse when an external event occurs. this mode is selected via the opm bit in the cr2 register. the one pulse mode uses the input capture1 function and the output compare1 function. procedure: to use one pulse mode: 1. load the oc1r register with the value corre- sponding to the length of the pulse (see the for- mula in section 4.3.3.7). 2. select the following in the cr1 register: using the olvl1 bit, select the level to be ap- plied to the ocmp1 pin after the pulse. using the olvl2 bit, select the level to be ap- plied to the ocmp1 pin during the pulse. select the edge of the active transition on the icap1 pin with the iedg1 bit (the icap1 pin must be configured as floating input). 3. select the following in the cr2 register: set the oc1e bit, the ocmp1 pin is then ded- icated to the output compare 1 function. set the opm bit. select the timer clock cc1-cc0 (see table 15). then, on a valid event on the icap1 pin, the coun- ter is initialized to fffch and olvl2 bit is loaded on the ocmp1 pin, the icf1 bit is set and the val- ue fffdh is loaded in the ic1r register. when the value of the counter is equal to the value of the contents of the oc1r register, the olvl1 bit is output on the ocmp1 pin, (see figure 31). notes: 1. the ocf1 bit cannot be set by hardware in one pulse mode but the ocf2 bit can generate an output compare interrupt. 2. the icf1 bit is set when an active edge occurs and can generate an interrupt if the icie bit is set. 3. when the pulse width modulation (pwm) and one pulse mode (opm) bits are both set, the pwm mode is the only active one. 4. if olvl1=olvl2 a continuous signal will be seen on the ocmp1 pin. 5. the icap1 pin can not be used to perform input capture. the icap2 pin can be used to perform input capture (icf2 can be set and ic2r can be loaded) but the user must take care that the counter is reset each time a valid edge occurs on the icap1 pin and icf1 can also generates interrupt if icie is set. 6. when the one pulse mode is used oc1r is dedicated to this mode. nevertheless oc2r and ocf2 can be used to indicate a period of time has been elapsed but cannot generate an output waveform because the level olvl2 is dedicated to the one pulse mode. folv2 folv1 olvl2 olvl1 event occurs counter = oc1r ocmp1 = olvl1 when when on icap1 one pulse mode cycle ocmp1 = olvl2 counter is reset to fffch icf1 bit is set 40
41/84 st72101/st72212/st72213 figure 31. one pulse mode timing example figure 32. pulse width modulation mode timing example counter .... fffc fffd fffe 2ed0 2ed1 2ed2 2ed3 fffc fffd olvl2 olvl2 olvl1 icap1 ocmp1 compare1 note: iedg1=1, oc1r=2ed0h, olvl1=0, olvl2=1 counter 34e2 fffc fffd fffe 2ed0 2ed1 2ed2 34e2 fffc olvl2 olvl2 olvl1 ocmp1 compare2 compare1 compare2 note: oc1r=2ed0h, oc2r=34e2, olvl1=0, olvl2= 1 41
42/84 st72101/st72212/st72213 16-bit timer (cont'd) 4.3.3.7 pulse width modulation mode pulse width modulation (pwm) mode enables the generation of a signal with a frequency and pulse length determined by the value of the oc1r and oc2r registers. the pulse width modulation mode uses the com- plete output compare 1 function plus the oc2r register, and so these functionality can not be used when the pwm mode is activated. procedure to use pulse width modulation mode: 1. load the oc2r register with the value corre- sponding to the period of the signal. 2. load the oc1r register with the value corre- sponding to the length of the pulse if (olvl1=0 and olvl2=1). 3. select the following in the cr1 register: using the olvl1 bit, select the level to be ap- plied to the ocmp1 pin after a successful comparison with oc1r register. using the olvl2 bit, select the level to be ap- plied to the ocmp1 pin after a successful comparison with oc2r register. 4. select the following in the cr2 register: set oc1e bit: the ocmp1 pin is then dedicat- ed to the output compare 1 function. set the pwm bit. select the timer clock (cc1-cc0) (see table 15). if olvl1=1 and olvl2=0 the length of the posi- tive pulse is the difference between the oc2r and oc1r registers. if olvl1=olvl2 a continuous signal will be seen on the ocmp1 pin. the oc i r register value required for a specific tim- ing application can be calculated using the follow- ing formula: where: t = desired output compare period (in sec- onds) f cpu = internal clock frequency presc = timer prescaler factor (2, 4 or 8 de- pending on cc1-cc0 bits, see table 15) the output compare 2 event causes the counter to be initialized to fffch (see figure 32). notes: 1. after a write instruction to the oc i hr register, the output compare function is inhibited until the oc i lr register is also written. therefore the input capture 1 function is inhib- ited but the input capture 2 is available. 2. the ocf1 and ocf2 bits cannot be set by hardware in pwm mode therefore the output compare interrupt is inhibited. 3. the icf1 bit is set by hardware when the coun- ter reaches the oc2r value and can produce a timer interrupt if the icie bit is set and the i bit is cleared. 4. in pwm mode the icap1 pin can not be used to perform input capture because it is discon- nected to the timer. the icap2 pin can be used to perform input capture (icf2 can be set and ic2r can be loaded) but the user must take care that the counter is reset each period and icf1 can also generates interrupt if icie is set. 5. when the pulse width modulation (pwm) and one pulse mode (opm) bits are both set, the pwm mode is the only active one. oc i r value = t * f cpu presc -5 counter ocmp1 = olvl2 counter = oc2r ocmp1 = olvl1 when when = oc1r pulse width modulation cycle counter is reset to fffch icf1 bit is set 42
43/84 st72101/st72212/st72213 16-bit timer (cont'd) 4.3.4 low power modes 4.3.5 interrupts note: the 16-bit timer interrupt events are con- nected to the same interrupt vector (see interrupts chapter). these events generate an interrupt if the corre- sponding enable control bit is set and the i-bit in the cc register is reset (rim instruction). mode description wait no effect on 16-bit timer. timer interrupts cause the device to exit from wait mode. halt 16-bit timer registers are frozen. in halt mode, the counter stops counting until halt mode is exited. counting resumes from the previous count when the mcu is woken up by an interrupt with aexit from halt modeo capability or from the counter reset value when the mcu is woken up by a reset. if an input capture event occurs on the icap i pin, the input capture detection circuitry is armed. consequent- ly, when the mcu is woken up by an interrupt with aexit from halt modeo capability, the icf i bit is set, and the counter value present when exiting from halt mode is captured into the ic i r register. interrupt event event flag enable control bit exit from wait exit from halt input capture 1 event/counter reset in pwm mode icf1 icie yes no input capture 2 event icf2 yes no output compare 1 event (not available in pwm mode) ocf1 ocie yes no output compare 2 event (not available in pwm mode) ocf2 yes no timer overflow event tof toie yes no 43
44/84 st72101/st72212/st72213 16-bit timer (cont'd) 4.3.6 register description each timer is associated with three control and status registers, and with six pairs of data registers (16-bit values) relating to the two input captures, the two output compares, the counter and the al- ternate counter. control register 1 (cr1) read/write reset value: 0000 0000 (00h) bit 7 = icie input capture interrupt enable. 0: interrupt is inhibited. 1: a timer interrupt is generated whenever the icf1 or icf2 bit of the sr register is set. bit 6 = ocie output compare interrupt enable. 0: interrupt is inhibited. 1: a timer interrupt is generated whenever the ocf1 or ocf2 bit of the sr register is set. bit 5 = toie timer overflow interrupt enable. 0: interrupt is inhibited. 1: a timer interrupt is enabled whenever the tof bit of the sr register is set. bit 4 = folv2 forced output compare 2. this bit is set and cleared by software. 0: no effect on the ocmp2 pin. 1: forces the olvl2 bit to be copied to the ocmp2 pin, if the oc2e bit is set and even if there is no successful comparison. bit 3 = folv1 forced output compare 1. this bit is set and cleared by software. 0: no effect on the ocmp1 pin. 1: forces olvl1 to be copied to the ocmp1 pin, if the oc1e bit is set and even if there is no suc- cessful comparison. bit 2 = olvl2 output level 2. this bit is copied to the ocmp2 pin whenever a successful comparison occurs with the oc2r reg- ister and ocxe is set in the cr2 register. this val- ue is copied to the ocmp1 pin in one pulse mode and pulse width modulation mode. bit 1 = iedg1 input edge 1. this bit determines which type of level transition on the icap1 pin will trigger the capture. 0: a falling edge triggers the capture. 1: a rising edge triggers the capture. bit 0 = olvl1 output level 1. the olvl1 bit is copied to the ocmp1 pin when- ever a successful comparison occurs with the oc1r register and the oc1e bit is set in the cr2 register. 70 icie ocie toie folv2 folv1 olvl2 iedg1 olvl1 44
45/84 st72101/st72212/st72213 16-bit timer (cont'd) control register 2 (cr2) read/write reset value: 0000 0000 (00h) bit 7 = oc1e output compare 1 pin enable. this bit is used only to output the signal from the timer on the ocmp1 pin (olv1 in output com- pare mode, both olv1 and olv2 in pwm and one-pulse mode). whatever the value of the oc1e bit, the output compare 1 function of the timer re- mains active. 0: ocmp1 pin alternate function disabled (i/o pin free for general-purpose i/o). 1: ocmp1 pin alternate function enabled. bit 6 = oc2e output compare 2 enable. this bit is used only to output the signal from the timer on the ocmp2 pin (olv2 in output com- pare mode). whatever the value of the oc2e bit, the output compare 2 function of the timer re- mains active. 0: ocmp2 pin alternate function disabled (i/o pin free for general-purpose i/o). 1: ocmp2 pin alternate function enabled. bit 5 = opm one pulse mode. 0: one pulse mode is not active. 1: one pulse mode is active, the icap1 pin can be used to trigger one pulse on the ocmp1 pin; the active transition is given by the iedg1 bit. the length of the generated pulse depends on the contents of the oc1r register. bit 4 = pwm pulse width modulation. 0: pwm mode is not active. 1: pwm mode is active, the ocmp1 pin outputs a programmable cyclic signal; the length of the pulse depends on the value of oc1r register; the period depends on the value of oc2r regis- ter. bit 3, 2 = cc1-cc0 clock control. the value of the timer clock depends on these bits: table 15. clock control bits bit 1 = iedg2 input edge 2. this bit determines which type of level transition on the icap2 pin will trigger the capture. 0: a falling edge triggers the capture. 1: a rising edge triggers the capture. bit 0 = exedg external clock edge. this bit determines which type of level transition on the external clock pin extclk will trigger the free running counter. 0: a falling edge triggers the free running counter. 1: a rising edge triggers the free running counter. 70 oc1e oc2e opm pwm cc1 cc0 iedg2 exedg timer clock cc1 cc0 f cpu /4 0 0 f cpu /2 0 1 f cpu /8 1 0 external clock (where available) 11 45
46/84 st72101/st72212/st72213 16-bit timer (cont'd) status register (sr) read only reset value: 0000 0000 (00h) the three least significant bits are not used. bit 7 = icf1 input capture flag 1. 0: no input capture (reset value). 1: an input capture has occurred or the counter has reached the oc2r value in pwm mode. to clear this bit, first read the sr register, then read or write the low byte of the ic1r (ic1lr) regis- ter. bit 6 = ocf1 output compare flag 1. 0: no match (reset value). 1: the content of the free running counter has matched the content of the oc1r register. to clear this bit, first read the sr register, then read or write the low byte of the oc1r (oc1lr) reg- ister. bit 5 = tof timer overflow. 0: no timer overflow (reset value). 1: the free running counter rolled over from ffffh to 0000h. to clear this bit, first read the sr reg- ister, then read or write the low byte of the cr (clr) register. note: reading or writing the aclr register does not clear tof. bit 4 = icf2 input capture flag 2. 0: no input capture (reset value). 1: an input capture has occurred.to clear this bit, first read the sr register, then read or write the low byte of the ic2r (ic2lr) register. bit 3 = ocf2 output compare flag 2. 0: no match (reset value). 1: the content of the free running counter has matched the content of the oc2r register. to clear this bit, first read the sr register, then read or write the low byte of the oc2r (oc2lr) reg- ister. bit 2-0 = reserved, forced by hardware to 0. input capture 1 high register (ic1hr) read only reset value: undefined this is an 8-bit read only register that contains the high part of the counter value (transferred by the input capture 1 event). input capture 1 low register (ic1lr) read only reset value: undefined this is an 8-bit read only register that contains the low part of the counter value (transferred by the in- put capture 1 event). output compare 1 high register (oc1hr) read/write reset value: 1000 0000 (80h) this is an 8-bit register that contains the high part of the value to be compared to the chr register. output compare 1 low register (oc1lr) read/write reset value: 0000 0000 (00h) this is an 8-bit register that contains the low part of the value to be compared to the clr register. 70 icf1 ocf1 tof icf2 ocf2 0 0 0 70 msb lsb 70 msb lsb 70 msb lsb 70 msb lsb 46
47/84 st72101/st72212/st72213 16-bit timer (cont'd) output compare 2 high register (oc2hr) read/write reset value: 1000 0000 (80h) this is an 8-bit register that contains the high part of the value to be compared to the chr register. output compare 2 low register (oc2lr) read/write reset value: 0000 0000 (00h) this is an 8-bit register that contains the low part of the value to be compared to the clr register. counter high register (chr) read only reset value: 1111 1111 (ffh) this is an 8-bit register that contains the high part of the counter value. counter low register (clr) read only reset value: 1111 1100 (fch) this is an 8-bit register that contains the low part of the counter value. a write to this register resets the counter. an access to this register after accessing the sr register clears the tof bit. alternate counter high register (achr) read only reset value: 1111 1111 (ffh) this is an 8-bit register that contains the high part of the counter value. alternate counter low register (aclr) read only reset value: 1111 1100 (fch) this is an 8-bit register that contains the low part of the counter value. a write to this register resets the counter. an access to this register after an access to sr register does not clear the tof bit in sr register. input capture 2 high register (ic2hr) read only reset value: undefined this is an 8-bit read only register that contains the high part of the counter value (transferred by the input capture 2 event). input capture 2 low register (ic2lr) read only reset value: undefined this is an 8-bit read only register that contains the low part of the counter value (transferred by the in- put capture 2 event). 70 msb lsb 70 msb lsb 70 msb lsb 70 msb lsb 70 msb lsb 70 msb lsb 70 msb lsb 70 msb lsb 47
48/84 st72101/st72212/st72213 16-bit timer (cont'd) table 16. 16-bit timer register map and reset values address (hex.) register name 76543210 timera: 32 timerb: 42 cr1 reset value icie 0 ocie 0 toie 0 folv2 0 folv1 0 olvl2 0 iedg1 0 olvl1 0 timera: 31 timerb: 41 cr2 reset value oc1e 0 oc2e 0 opm 0 pwm 0 cc1 0 cc0 0 iedg2 0 exedg 0 timera: 33 timerb: 43 sr reset value icf1 0 ocf1 0 tof 0 icf2 0 ocf2 0 - 0 - 0 - 0 timera: 34 timerb: 44 ic1hr reset value msb - ------ lsb - timera: 35 timerb: 45 ic1lr reset value msb - ------ lsb - timera: 36 timerb: 46 oc1hr reset value msb 1 - 0 - 0 - 0 - 0 - 0 - 0 lsb 0 timera: 37 timerb: 47 oc1lr reset value msb 0 - 0 - 0 - 0 - 0 - 0 - 0 lsb 0 timera: 3e timerb: 4e oc2hr reset value msb 1 - 0 - 0 - 0 - 0 - 0 - 0 lsb 0 timera: 3f timerb: 4f oc2lr reset value msb 0 - 0 - 0 - 0 - 0 - 0 - 0 lsb 0 timera: 38 timerb: 48 chr reset value msb 1111111 lsb 1 timera: 39 timerb: 49 clr reset value msb 1111110 lsb 0 timera: 3a timerb: 4a achr reset value msb 1111111 lsb 1 timera: 3b timerb: 4b aclr reset value msb 1111110 lsb 0 timera: 3c timerb: 4c ic2hr reset value msb - ------ lsb - timera: 3d timerb: 4d ic2lr reset value msb - ------ lsb - 48
49/84 st72101/st72212/st72213 4.4 serial peripheral interface (spi) 4.4.1 introduction the serial peripheral interface (spi) allows full- duplex, synchronous, serial communication with external devices. an spi system may consist of a master and one or more slaves or a system in which devices may be either masters or slaves. the spi is normally used for communication be- tween the microcontroller and external peripherals or another microcontroller. refer to the pin description chapter for the device- specific pin-out. 4.4.2 main features n full duplex, three-wire synchronous transfers n master or slave operation n four master mode frequencies n maximum slave mode frequency = fcpu/2. n four programmable master bit rates n programmable clock polarity and phase n end of transfer interrupt flag n write collision flag protection n master mode fault protection capability. 4.4.3 general description the spi is connected to external devices through 4 alternate pins: miso: master in slave out pin mosi: master out slave in pin sck: serial clock pin ss: slave select pin a basic example of interconnections between a single master and a single slave is illustrated on figure 33. the mosi pins are connected together as are miso pins. in this way data is transferred serially between master and slave (most significant bit first). when the master device transmits data to a slave device via mosi pin, the slave device responds by sending data to the master device via the miso pin. this implies full duplex transmission with both data out and data in synchronized with the same clock signal (which is provided by the master de- vice via the sck pin). thus, the byte transmitted is replaced by the byte received and eliminates the need for separate transmit-empty and receiver-full bits. a status flag is used to indicate that the i/o operation is com- plete. four possible data/clock timing relationships may be chosen (see figure 36) but master and slave must be programmed with the same timing mode. figure 33. serial peripheral interface master/slave 8-bit shift register spi clock generator 8-bit shift register miso mosi mosi miso sck sck slave master ss ss +5v msbit lsbit msbit lsbit 49
50/84 st72101/st72212/st72213 serial peripheral interface (cont'd) figure 34. serial peripheral interface block diagram dr read buffer 8-bit shift register write read internal bus spi spie spe spr2 mstr cpha spr0 spr1 cpol spif wcol modf serial clock generator mosi miso ss sck control state cr sr - -- -- it request master control 50
51/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.4 functional description figure 33 shows the serial peripheral interface (spi) block diagram. this interface contains 3 dedicated registers: a control register (cr) a status register (sr) a data register (dr) refer to the cr, sr and dr registers in section 4.4.7for the bit definitions. 4.4.4.1 master configuration in a master configuration, the serial clock is gener- ated on the sck pin. procedure select the spr0 & spr1 bits to define the se- rial clock baud rate (see cr register). select the cpol and cpha bits to define one of the four relationships between the data transfer and the serial clock (see figure 36). the ss pin must be connected to a high level signal during the complete byte transmit se- quence. the mstr and spe bits must be set (they re- main set only if the ss pin is connected to a high level signal). in this configuration the mosi pin is a data output and to the miso pin is a data input. transmit sequence the transmit sequence begins when a byte is writ- ten the dr register. the data byte is parallel loaded into the 8-bit shift register (from the internal bus) during a write cycle and then shifted out serially to the mosi pin most significant bit first. when data transfer is complete: the spif bit is set by hardware an interrupt is generated if the spie bit is set and the i bit in the ccr register is cleared. during the last clock cycle the spif bit is set, a copy of the data byte received in the shift register is moved to a buffer. when the dr register is read, the spi peripheral returns this buffered value. clearing the spif bit is performed by the following software sequence: 1. an access to the sr register while the spif bit is set 2. a write or a read of the dr register. note: while the spif bit is set, all writes to the dr 51
52/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.4.2 slave configuration in slave configuration, the serial clock is received on the sck pin from the master device. the value of the spr0 & spr1 bits is not used for the data transfer. procedure for correct data transfer, the slave device must be in the same timing mode as the mas- ter device (cpol and cpha bits). see figure 36. the ss pin must be connected to a low level signal during the complete byte transmit se- quence. clear the mstr bit and set the spe bit to as- sign the pins to alternate function. in this configuration the mosi pin is a data input and the miso pin is a data output. transmit sequence the data byte is parallel loaded into the 8-bit shift register (from the internal bus) during a write cycle and then shifted out serially to the miso pin most significant bit first. the transmit sequence begins when the slave de- vice receives the clock signal and the most signifi- cant bit of the data on its mosi pin. when data transfer is complete: the spif bit is set by hardware an interrupt is generated if spie bit is set and i bit in ccr register is cleared. during the last clock cycle the spif bit is set, a copy of the data byte received in the shift register is moved to a buffer. when the dr register is read, the spi peripheral returns this buffered value. clearing the spif bit is performed by the following software sequence: 1. an access to the sr register while the spif bit is set. 2. a write or a read of the dr register. notes: while the spif bit is set, all writes to the dr register are inhibited until the sr register is read. the spif bit can be cleared during a second transmission; however, it must be cleared before the second spif bit in order to prevent an overrun condition (see section 4.4.4.6). depending on the cpha bit, the ss pin has to be set to write to the dr register between each data byte transfer to avoid a write collision (see section 4.4.4.4). 52
53/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.4.3 data transfer format during an spi transfer, data is simultaneously transmitted (shifted out serially) and received (shifted in serially). the serial clock is used to syn- chronize the data transfer during a sequence of eight clock pulses. the ss pin allows individual selection of a slave device; the other slave devices that are not select- ed do not interfere with the spi transfer. clock phase and clock polarity four possible timing relationships may be chosen by software, using the cpol and cpha bits. the cpol (clock polarity) bit controls the steady state value of the clock when no data is being transferred. this bit affects both master and slave modes. the combination between the cpol and cpha (clock phase) bits selects the data capture clock edge. figure 36, shows an spi transfer with the four combinations of the cpha and cpol bits. the di- agram may be interpreted as a master or slave timing diagram where the sck pin, the miso pin, the mosi pin are directly connected between the master and the slave device. the ss pin is the slave device select input and can be driven by the master device. the master device applies data to its mosi pin- clock edge before the capture clock edge. cpha bit is set the second edge on the sck pin (falling edge if the cpol bit is reset, rising edge if the cpol bit is set) is the msbit capture strobe. data is latched on the occurrence of the first clock transition. no write collision should occur even if the ss pin stays low during a transfer of several bytes (see figure 35). cpha bit is reset the first edge on the sck pin (falling edge if cpol bit is set, rising edge if cpol bit is reset) is the msbit capture strobe. data is latched on the oc- currence of the second clock transition. this pin must be toggled high and low between each byte transmitted (see figure 35). to protect the transmission from a write collision a low value on the ss pin of a slave device freezes the data in its dr register and does not allow it to be altered. therefore the ss pin must be high to write a new data byte in the dr without producing a write collision. figure 35. cpha / ss timing diagram mosi/miso master ss slave ss (cpha=0) slave ss (cpha=1) byte 1 byte 2 byte 3 vr02131a 53
54/84 st72101/st72212/st72213 serial peripheral interface (cont'd) figure 36. data clock timing diagram cpol = 1 cpol = 0 msbit bit 6 bit 5 bit 4 bit3 bit 2 bit 1 lsbit miso (from master) mosi (from slave) ss (to slave) capture strobe cpha =1 cpol = 1 cpol = 0 msbit bit 6 bit 5 bit 4 bit3 bit 2 bit 1 lsbit msbit bit 6 bit 5 bit 4 bit3 bit 2 bit 1 lsbit miso (from master) mosi ss (to slave) capture strobe cpha =0 note: this figure should not be used as a replacement for parametric information. refer to the electrical characteristics chapter. (from slave) vr02131b msbit bit 6 bit 5 bit 4 bit3 bit 2 bit 1 lsbit 54
55/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.4.4 write collision error a write collision occurs when the software tries to write to the dr register while a data transfer is tak- ing place with an external device. when this hap- pens, the transfer continues uninterrupted; and the software write will be unsuccessful. write collisions can occur both in master and slave mode. note: a oread collisiono will never occur since the received data byte is placed in a buffer in which access is always synchronous with the mcu oper- ation. in slave mode when the cpha bit is set: the slave device will receive a clock (sck) edge prior to the latch of the first data transfer. this first clock edge will freeze the data in the slave device dr register and output the msbit on to the exter- nal miso pin of the slave device. the ss pin low state enables the slave device but the output of the msbit onto the miso pin does not take place until the first data transfer clock edge. when the cpha bit is reset: data is latched on the occurrence of the first clock transition. the slave device does not have any way of knowing when that transition will occur; therefore, the slave device collision occurs when software attempts to write the dr register after its ss pin has been pulled low. for this reason, the ss pin must be high, between each data byte transfer, to allow the cpu to write in the dr register without generating a write colli- sion. in master mode collision in the master device is defined as a write of the dr register while the internal serial clock (sck) is in the process of transfer. the ss pin signal must be always high on the master device. wcol bit the wcol bit in the sr register is set if a write collision occurs. no spi interrupt is generated when the wcol bit is set (the wcol bit is a status flag only). clearing the wcol bit is done through a software sequence (see figure 37). figure 37. clearing the wcol bit (write collision flag) software sequence clearing sequence after spif = 1 (end of a data byte transfer) 1st step read sr read dr write dr 2nd step spif =0 wcol=0 spif =0 wcol=0 if no transfer has started wcol=1 if a transfer has started clearing sequence before spif = 1 (during a data byte transfer) 1st step 2nd step wcol=0 before the 2nd step read sr read dr note: writing in dr register in- stead of reading in it do not reset wcol bit read sr or then then then 55
56/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.4.5 master mode fault master mode fault occurs when the master device has its ss pin pulled low, then the modf bit is set. master mode fault affects the spi peripheral in the following ways: the modf bit is set and an spi interrupt is generated if the spie bit is set. the spe bit is reset. this blocks all output from the device and disables the spi periph- eral. the mstr bit is reset, thus forcing the device into slave mode. clearing the modf bit is done through a software sequence: 1. a read or write access to the sr register while the modf bit is set. 2. a write to the cr register. notes: to avoid any multiple slave conflicts in the case of a system comprising several mcus, the ss pin must be pulled high during the clearing se- quence of the modf bit. the spe and mstr bits may be restored to their original state during or af- ter this clearing sequence. hardware does not allow the user to set the spe and mstr bits while the modf bit is set except in the modf bit clearing sequence. in a slave device the modf bit can not be set, but in a multi master configuration the device can be in slave mode with this modf bit set. the modf bit indicates that there might have been a multi-master conflict for system control and allows a proper exit from system operation to a re- set or default system state using an interrupt rou- tine. 4.4.4.6 overrun condition an overrun condition occurs, when the master de- vice has sent several data bytes and the slave de- vice has not cleared the spif bit issuing from the previous data byte transmitted. in this case, the receiver buffer contains the byte sent after the spif bit was last cleared. a read to the dr register returns this byte. all other bytes are lost. this condition is not detected by the spi peripher- al. 56
57/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.4.7 single master and multimaster configurations there are two types of spi systems: single master system multimaster system single master system a typical single master system may be configured, using an mcu as the master and four mcus as slaves (see figure 38). the master device selects the individual slave de- vices by using four pins of a parallel port to control the four ss pins of the slave devices. the ss pins are pulled high during reset since the master device ports will be forced to be inputs at that time, thus disabling the slave devices. note: to prevent a bus conflict on the miso line the master allows only one slave device during a transmission. for more security, the slave device may respond to the master with the received data byte. then the master will receive the previous byte back from the slave device if all miso and mosi pins are con- nected and the slave has not written its dr regis- ter. other transmission security methods can use ports for handshake lines or data bytes with com- mand fields. multi-master system a multi-master system may also be configured by the user. transfer of master control could be im- plemented using a handshake method through the i/o ports or by an exchange of code messages through the serial peripheral interface system. the multi-master system is principally handled by the mstr bit in the cr register and the modf bit in the sr register. figure 38. single master configuration miso mosi mosi mosi mosi mosi miso miso miso miso ss ss ss ss ss sck sck sck sck sck 5v ports slave mcu slave mcu slave mcu slave mcu master mcu 57
58/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.5 low power modes 4.4.6 interrupts note : the spi interrupt events are connected to the same interrupt vector (see interrupts chapter). they generate an interrupt if the corresponding enable control bit is set and the i-bit in the cc reg- ister is reset (rim instruction). mode description wait no effect on spi. spi interrupt events cause the device to exit from wait mode. halt spi registers are frozen. in halt mode, the spi is inactive. spi operation resumes when the mcu is woken up by an interrupt with aexit from halt modeo capability. interrupt event event flag enable control bit exit from wait exit from halt spi end of transfer event spif spie yes no master mode fault event modf yes no 58
59/84 st72101/st72212/st72213 serial peripheral interface (cont'd) 4.4.7 register description control register (cr) read/write reset value: 0000xxxx (0xh) bit 7 = spie serial peripheral interrupt enable. this bit is set and cleared by software. 0: interrupt is inhibited 1: an spi interrupt is generated whenever spif=1 or modf=1 in the sr register bit 6 = spe serial peripheral output enable. this bit is set and cleared by software. it is also cleared by hardware when, in master mode, ss=0 (see section 4.4.4.5 master mode fault). 0: i/o port connected to pins 1: spi alternate functions connected to pins the spe bit is cleared by reset, so the spi periph- eral is not initially connected to the external pins. bit 5 = spr2 divider enable . this bit is set and cleared by software and it is cleared by reset. it is used with the spr[1:0] bits to set the baud rate. refer to table 17. 0: divider by 2 enabled 1: divider by 2 disabled bit 4 = mstr master. this bit is set and cleared by software. it is also cleared by hardware when, in master mode, ss=0 (see section 4.4.4.5 master mode fault). 0: slave mode is selected 1: master mode is selected, the function of the sck pin changes from an input to an output and the functions of the miso and mosi pins are re- versed. bit 3 = cpol clock polarity. this bit is set and cleared by software. this bit de- termines the steady state of the serial clock. the cpol bit affects both the master and slave modes. 0: the steady state is a low value at the sck pin. 1: the steady state is a high value at the sck pin. bit 2 = cpha clock phase. this bit is set and cleared by software. 0: the first clock transition is the first data capture edge. 1: the second clock transition is the first capture edge. bit 1:0 = spr[1 : 0] serial peripheral rate. these bits are set and cleared by software.used with the spr2 bit, they select one of six baud rates to be used as the serial clock when the device is a master. these 2 bits have no effect in slave mode. table 17. serial peripheral baud rate 70 spie spe spr2 mstr cpol cpha spr1 spr0 serial clock spr2 spr1 spr0 f cpu /2 1 0 0 f cpu /8 0 0 0 f cpu /16 0 0 1 f cpu /32 1 1 0 f cpu /64 0 1 0 f cpu /128 0 1 1 59
60/84 st72101/st72212/st72213 serial peripheral interface (cont'd) status register (sr) read only reset value: 0000 0000 (00h) bit 7 = spif serial peripheral data transfer flag. this bit is set by hardware when a transfer has been completed. an interrupt is generated if spie=1 in the cr register. it is cleared by a soft- ware sequence (an access to the sr register fol- lowed by a read or write to the dr register). 0: data transfer is in progress or has been ap- proved by a clearing sequence. 1: data transfer between the device and an exter- nal device has been completed. note: while the spif bit is set, all writes to the dr register are inhibited. bit 6 = wcol write collision status. this bit is set by hardware when a write to the dr register is done during a transmit sequence. it is cleared by a software sequence (see figure 37). 0: no write collision occurred 1: a write collision has been detected bit 5 = unused. bit 4 = modf mode fault flag. this bit is set by hardware when the ss pin is pulled low in master mode (see section 4.4.4.5 master mode fault). an spi interrupt can be gen- erated if spie=1 in the cr register. this bit is cleared by a software sequence (an access to the sr register while modf=1 followed by a write to the cr register). 0: no master mode fault detected 1: a fault in master mode has been detected bits 3-0 = unused. data i/o register (dr) read/write reset value: undefined the dr register is used to transmit and receive data on the serial bus. in the master device only a write to this register will initiate transmission/re- ception of another byte. notes: during the last clock cycle the spif bit is set, a copy of the received data byte in the shift register is moved to a buffer. when the user reads the serial peripheral data i/o register, the buffer is actually being read. warning: a write to the dr register places data directly into the shift register for transmission. a write to the the dr register returns the value lo- cated in the buffer and not the contents of the shift register (see figure 34 ). 70 spif wcol - modf - - - - 70 d7 d6 d5 d4 d3 d2 d1 d0 60
61/84 st72101/st72212/st72213 serial peripheral interface (cont'd) table 18. spi register map and reset values address (hex.) register name 76543210 21 dr reset value d7 x d6 x d5 x d4 x d3 x d2 x d1 x d0 x 22 cr reset value spie 0 spe 0 spr2 0 mstr 0 cpol x cpha x spr1 x spr0 x 23 sr reset value spif 0 wcol 0 - 0 modf 0 - 0 - 0 - 0 - 0 61
62/84 st72101/st72212/st72213 4.5 8-bit a/d converter (adc) 4.5.1 introduction the on-chip analog to digital converter (adc) pe- ripheral is a 8-bit, successive approximation con- verter with internal sample and hold circuitry. this peripheral has up to 8 multiplexed analog input channels (refer to device pin out description) that allow the peripheral to convert the analog voltage levels from up to 8 different sources. the result of the conversion is stored in a 8-bit data register. the a/d converter is controlled through a control/status register. 4.5.2 main features n 8-bit conversion n up to 8 channels with multiplexed input n linear successive approximation n data register (dr) which contains the results n conversion complete status flag n on/off bit (to reduce consumption) the block diagram is shown in figure 39. figure 39. adc block diagram sample analog mux ain0 ain1 ain2 ain3 ain4 ain5 ain6 ain7 (control status register) csr (data register) dr & hold f cpu analog to digital converter coco 0ch0 ch1 ch2 - - adon ad7 ad4 ad0 ad1 ad2 ad3 ad6 ad5 62
63/84 st72101/st72212/st72213 8-bit a/d converter (adc) (cont'd) 4.5.3 functional description the high level reference voltage v dda must be connected externally to the v dd pin. the low level reference voltage v ssa must be connected exter- nally to the v ss pin. in some devices (refer to de- vice pin out description) high and low level refer- ence voltages are internally connected to the v dd and v ss pins. conversion accuracy may therefore be degraded by voltage drops and noise in the event of heavily loaded or badly decoupled power supply lines. figure 40. recommended ext. connections characteristics: the conversion is monotonic, meaning the result never decreases if the analog input does not and never increases if the analog input does not. if input voltage is greater than or equal to v dd (voltage reference high) then results = ffh (full scale) without overflow indication. if input voltage v ss (voltage reference low) then the results = 00h. the conversion time is 64 cpu clock cycles in- cluding a sampling time of 31.5 cpu clock cycles. r ain is the maximum recommended impedance for an analog input signal. if the impedance is too high, this will result in a loss of accuracy due to leakage and sampling not being completed in the alloted time. the a/d converter is linear and the digital result of the conversion is given by the formula: where reference voltage is v dd -v ss . the accuracy of the conversion is described in the electrical characteristics section. procedure: refer to the csr and dr register description sec- tion for the bit definitions. each analog input pin must be configured as input, no pull-up, no interrupt. refer to the ?i/o ports? chapter. using these pins as analog inputs does not affect the ability of the port to be read as a logic input. in the csr register: select the ch2 to ch0 bits to assign the ana- log channel to convert. refer to table 19. set the adon bit. then the a/d converter is enabled after a stabilization time (typically 30 m s). it then performs a continuous conversion of the selected channel. when a conversion is complete the coco bit is set by hardware. no interrupt is generated. the result is in the dr register. a write to the csr register aborts the current con- version, resets the coco bit and starts a new conversion. 4.5.4 low power modes note: the a/d converter may be disabled by re- setting the adon bit. this feature allows reduced power consumption when no conversion is need- ed. 4.5.5 interrupts none st7 px.x/ainx v dda v ssa 1k v dd 0.1 m f r ain v ain digital result = 255 x input voltage reference voltage mode description wait no effect on a/d converter halt a/d converter disabled. after wakeup from halt mode, the a/d converter requires a stabilisation time before accurate conversions can be performed. 63
64/84 st72101/st72212/st72213 8-bit a/d converter (adc) (cont'd) 4.5.6 register description control/status register (csr) read/write reset value: 0000 0000 (00h) bit 7 = coco conversion complete this bit is set by hardware. it is cleared by soft- ware reading the result in the dr register or writing to the csr register. 0: conversion is not complete. 1: conversion can be read from the dr register. bit 6 = reserved . must always be cleared. bit 5 = adon a/d converter on this bit is set and cleared by software. 0: a/d converter is switched off. 1: a/d converter is switched on. note: a typically 30 m s delay time is necessary for the adc to stabilize when the adon bit is set. bit 4 = reserved . forced by hardware to 0. bit 3 = reserved . must always be cleared. bits 2-0: ch[2:0] channel selection these bits are set and cleared by software. they select the analog input to convert. table 19. channel selection * important note: the number of pins and the channel selection vary according to the device. refer to the device pinout). data register (dr) read only reset value: 0000 0000 (00h) bit 7:0 = ad[7:0] analog converted value this register contains the converted analog value in the range 00h to ffh. reading this register reset the coco flag. table 20. adc register map 70 coco - adon 0 - ch2 ch1 ch0 pin* ch2 ch1 ch0 ain0 0 0 0 ain1 0 0 1 ain2 0 1 0 ain3 0 1 1 ain4 1 0 0 ain5 1 0 1 ain6 1 1 0 ain7 1 1 1 70 ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 address (hex.) register name 765 4 3210 70 reset value dr ad7 0 ad6 0 ad5 0 ad4 0 ad3 0 ad2 0 ad1 0 ad0 0 71 reset value csr coco 0 - 0 adon 0 0 0 - 0 ch2 0 ch1 0 ch0 0 64
65/84 st72101/st72212/st72213 5 instruction set 5.1 st7 addressing modes the st7 core features 17 different addressing modes which can be classified in 7 main groups: the st7 instruction set is designed to minimize the number of bytes required per instruction: to do so, most of the addressing modes may be subdi- vided in two sub-modes called long and short: long addressing mode is more powerful be- cause it can use the full 64 kbyte address space, however it uses more bytes and more cpu cy- cles. short addressing mode is less powerful because it can generally only access page zero (0000h - 00ffh range), but the instruction size is more compact, and faster. all memory to memory in- structions use short addressing modes only (clr, cpl, neg, bset, bres, btjt, btjf, inc, dec, rlc, rrc, sll, srl, sra, swap) the st7 assembler optimizes the use of long and short addressing modes. table 21. st7 addressing mode overview note 1. at the time the instruction is executed, the program counter (pc) points to the instruction follow- ing jrxx. addressing mode example inherent nop immediate ld a,#$55 direct ld a,$55 indexed ld a,($55,x) indirect ld a,([$55],x) relative jrne loop bit operation bset byte,#5 mode syntax destination/ source pointer address (hex.) pointer size (hex.) length (bytes) inherent nop + 0 immediate ld a,#$55 + 1 short direct ld a,$10 00..ff + 1 long direct ld a,$1000 0000..ffff + 2 no offset direct indexed ld a,(x) 00..ff + 0 (with x register) + 1 (with y register) short direct indexed ld a,($10,x) 00..1fe + 1 long direct indexed ld a,($1000,x) 0000..ffff + 2 short indirect ld a,[$10] 00..ff 00..ff byte + 2 long indirect ld a,[$10.w] 0000..ffff 00..ff word + 2 short indirect indexed ld a,([$10],x) 00..1fe 00..ff byte + 2 long indirect indexed ld a,([$10.w],x) 0000..ffff 00..ff word + 2 relative direct jrne loop pc-128/pc+127 1) +1 relative indirect jrne [$10] pc-128/pc+127 1) 00..ff byte + 2 bit direct bset $10,#7 00..ff + 1 bit indirect bset [$10],#7 00..ff 00..ff byte + 2 bit direct relative btjt $10,#7,skip 00..ff + 2 bit indirect relative btjt [$10],#7,skip 00..ff 00..ff byte + 3 65
66/84 st72101/st72212/st72213 st7 addressing modes (cont'd) 5.1.1 inherent all inherent instructions consist of a single byte. the opcode fully specifies all the required informa- tion for the cpu to process the operation. 5.1.2 immediate immediate instructions have two bytes, the first byte contains the opcode, the second byte con- tains the the operand value. . 5.1.3 direct in direct instructions, the operands are referenced by their memory address. the direct addressing mode consists of two sub- modes: direct (short) the address is a byte, thus requires only one byte after the opcode, but only allows 00 - ff address- ing space. direct (long) the address is a word, thus allowing 64 kbyte ad- dressing space, but requires 2 bytes after the op- code. 5.1.4 indexed (no offset, short, long) in this mode, the operand is referenced by its memory address, which is defined by the unsigned addition of an index register (x or y) with an offset. the indirect addressing mode consists of three sub-modes: indexed (no offset) there is no offset, (no extra byte after the opcode), and allows 00 - ff addressing space. indexed (short) the offset is a byte, thus requires only one byte af- ter the opcode and allows 00 - 1fe addressing space. indexed (long) the offset is a word, thus allowing 64 kbyte ad- dressing space and requires 2 bytes after the op- code. 5.1.5 indirect (short, long) the required data byte to do the operation is found by its memory address, located in memory (point- er). the pointer address follows the opcode. the indi- rect addressing mode consists of two sub-modes: indirect (short) the pointer address is a byte, the pointer size is a byte, thus allowing 00 - ff addressing space, and requires 1 byte after the opcode. indirect (long) the pointer address is a byte, the pointer size is a word, thus allowing 64 kbyte addressing space, and requires 1 byte after the opcode. inherent instruction function nop no operation trap s/w interrupt wfi wait for interrupt (low power mode) halt halt oscillator (lowest power mode) ret sub-routine return iret interrupt sub-routine return sim set interrupt mask rim reset interrupt mask scf set carry flag rcf reset carry flag rsp reset stack pointer ld load clr clear push/pop push/pop to/from the stack inc/dec increment/decrement tnz test negative or zero cpl, neg 1 or 2 complement mul byte multiplication sll, srl, sra, rlc, rrc shift and rotate operations swap swap nibbles immediate instruction function ld load cp compare bcp bit compare and, or, xor logical operations adc, add, sub, sbc arithmetic operations 66
67/84 st72101/st72212/st72213 st7 addressing modes (cont'd) 5.1.6 indirect indexed (short, long) this is a combination of indirect and short indexed addressing modes. the operand is referenced by its memory address, which is defined by the un- signed addition of an index register value (x or y) with a pointer value located in memory. the point- er address follows the opcode. the indirect indexed addressing mode consists of two sub-modes: indirect indexed (short) the pointer address is a byte, the pointer size is a byte, thus allowing 00 - 1fe addressing space, and requires 1 byte after the opcode. indirect indexed (long) the pointer address is a byte, the pointer size is a word, thus allowing 64 kbyte addressing space, and requires 1 byte after the opcode. table 22. instructions supporting direct, indexed, indirect and indirect indexed addressing modes 5.1.7 relative mode (direct, indirect) this addressing mode is used to modify the pc register value, by adding an 8-bit signed offset to it. the relative addressing mode consists of two sub- modes: relative (direct) the offset is following the opcode. relative (indirect) the offset is defined in memory, which address follows the opcode. long and short instructions function ld load cp compare and, or, xor logical operations adc, add, sub, sbc arithmetic addition/subtrac- tion operations bcp bit compare short instructions only functio n clr clear inc, dec increment/decrement tnz test negative or zero cpl, neg 1 or 2 complement bset, bres bit operations btjt, btjf bit test and jump opera- tions sll, srl, sra, rlc, rrc shift and rotate operations swap swap nibbles call, jp call or jump subroutine available relative direct/ indirect instructions function jrxx conditional jump callr call relative 67
68/84 st72101/st72212/st72213 5.2 instruction groups the st7 family devices use an instruction set consisting of 63 instructions. the instructions may be subdivided into 13 main groups as illustrated in the following table: using a pre-byte the instructions are described with one to four bytes. in order to extend the number of available op- codes for an 8-bit cpu (256 opcodes), three differ- ent prebyte opcodes are defined. these prebytes modify the meaning of the instruction they pre- cede. the whole instruction becomes: pc-2 end of previous instruction pc-1 prebyte pc opcode pc+1 additional word (0 to 2) according to the number of bytes required to compute the ef- fective address these prebytes enable instruction in y as well as indirect addressing modes to be implemented. they precede the opcode of the instruction in x or the instruction using direct addressing mode. the prebytes are: pdy 90 replace an x based instruction using immediate, direct, indexed, or inherent ad- dressing mode by a y one. pix 92 replace an instruction using di- rect, direct bit, or direct relative addressing mode to an instruction using the corresponding indirect addressing mode. it also changes an instruction using x indexed ad- dressing mode to an instruction using indirect x in- dexed addressing mode. piy 91 replace an instruction using x in- direct indexed addressing mode by a y one. load and transfer ld clr stack operation push pop rsp increment/decrement inc dec compare and tests cp tnz bcp logical operations and or xor cpl neg bit operation bset bres conditional bit test and branch btjt btjf arithmetic operations adc add sub sbc mul shift and rotates sll srl sra rlc rrc swap sla unconditional jump or call jra jrt jrf jp call callr nop ret conditional branch jrxx interruption management trap wfi halt iret code condition flag modification sim rim scf rcf 68
69/84 st72101/st72212/st72213 instruction groups (cont'd) mnemo description function/example dst src h i n z c adc add with carry a = a + m + c a m h n z c add addition a = a + m a m h n z c and logical and a = a . m a m n z bcp bit compare a, memory tst (a . m) a m n z bres bit reset bres byte, #3 m bset bit set bset byte, #3 m btjf jump if bit is false (0) btjf byte, #3, jmp1 m c btjt jump if bit is true (1) btjt byte, #3, jmp1 m c call call subroutine callr call subroutine relative clr clear reg, m 0 1 cp arithmetic compare tst(reg - m) reg m n z c cpl one complement a = ffh-a reg, m n z 1 dec decrement dec y reg, m n z halt halt 0 iret interrupt routine return pop cc, a, x, pc h i n z c inc increment inc x reg, m n z jp absolute jump jp [tbl.w] jra jump relative always jrt jump relative jrf never jump jrf * jrih jump if ext. interrupt = 1 jril jump if ext. interrupt = 0 jrh jump if h = 1 h = 1 ? jrnh jump if h = 0 h = 0 ? jrm jump if i = 1 i = 1 ? jrnm jump if i = 0 i = 0 ? jrmi jump if n = 1 (minus) n = 1 ? jrpl jump if n = 0 (plus) n = 0 ? jreq jump if z = 1 (equal) z = 1 ? jrne jump if z = 0 (not equal) z = 0 ? jrc jump if c = 1 c = 1 ? jrnc jump if c = 0 c = 0 ? jrult jump if c = 1 unsigned < jruge jump if c = 0 jmp if unsigned >= jrugt jump if (c + z = 0) unsigned > 69
70/84 st72101/st72212/st72213 instruction groups (cont'd) mnemo description function/example dst src h i n z c jrule jump if (c + z = 1) unsigned <= ld load dst <= src reg, m m, reg n z mul multiply x,a = x * a a, x, y x, y, a 0 0 neg negate (2's compl) neg $10 reg, m n z c nop no operation or or operation a = a + m a m n z pop pop from the stack pop reg reg m pop cc cc m h i n z c push push onto the stack push y m reg, cc rcf reset carry flag c = 0 0 ret subroutine return rim enable interrupts i = 0 0 rlc rotate left true c c <= dst <= c reg, m n z c rrc rotate right true c c => dst => c reg, m n z c rsp reset stack pointer s = max allowed sbc subtract with carry a = a - m - c a m n z c scf set carry flag c = 1 1 sim disable interrupts i = 1 1 sla shift left arithmetic c <= dst <= 0 reg, m n z c sll shift left logic c <= dst <= 0 reg, m n z c srl shift right logic 0 => dst => c reg, m 0 z c sra shift right arithmetic dst7 => dst => c reg, m n z c sub subtraction a = a - m a m n z c swap swap nibbles dst[7..4] <=> dst[3..0] reg, m n z tnz test for neg & zero tnz lbl1 n z trap s/w trap s/w interrupt 1 wfi wait for interrupt 0 xor exclusive or a = a xor m a m n z 70
71/84 st72101/st72212/st72213 6 electrical characteristics 6.1 absolute maximum ratings this product contains devices to protect the inputs against damage due to high static voltages, how- ever it is advisable to take normal precaution to avoid application of any voltage higher than the specified maximum rated voltages. for proper operation it is recommended that v i and v o be higher than v ss and lower than v dd . reliability is enhanced if unused inputs are con- nected to an appropriate logic voltage level (v dd or v ss ). power considerations .the average chip-junc- tion temperature, t j , in celsius can be obtained from: t j = ta + pd x rthja where: t a = ambient temperature. rthja = package thermal resistance (junction-to ambient). p d =p int +p port . p int =i dd xv dd (chip internal power). p port =port power dissipation determined by the user) note: stresses above those listed as aabsolute maximum ratingso may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these conditions is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. symbol parameter value unit v dd supply voltage -0.3 to 6.0 v v i input voltage v ss - 0.3 to v dd + 0.3 v v ai analog input voltage (a/d converter) v ss - 0.3 to v dd + 0.3 v v o output voltage v ss - 0.3 to v dd + 0.3 v iv dd total current into v dd (source) 80 ma iv ss total current out of v ss (sink) 80 ma t j junction temperature 150 c t stg storage temperature -60 to 150 c 71
72/84 st72101/st72212/st72213 6.2 recommended operating conditions note 1 : a/d operation and oscillator start-up are not guaranteed below 1mhz. figure 41. maximum operating frequency (f osc ) versus supply voltage (v dd ) symbol parameter test condition s value unit min. typ. max. t a operating temperature 1 suffix version 0 70 c 6 suffix version -40 85 c 3 suffix version -40 125 c v dd operating supply voltage f osc = 16 mhz (1 & 6 suffix) f osc = 8 mhz 3.5 3.0 5.5 5.5 v f osc oscillator frequency v dd = 3.0v v dd = 3.5v (1 & 6 suffix) 0 1) 0 1) 8 16 mhz f osc [mhz] supplly voltage [v] 16 8 4 1 0 2.5 3 3.5 4 4.5 5 5.5 functionality not guaranteed in this area functionality not guaranteed in this area with resonator functionality guaranteed in this area functionality not guaranteed in this area for temperature higher than 85 c 72
73/84 st72101/st72212/st72213 6.3 dc electrical characteristics (t a = -40 c to +125 c and v dd = 5v unless otherwise specified) notes: 1. hysteresis voltage between switching levels. based on characterisation results, not tested. 2. cpu running with memory access, no dc load or activity on i/o's; clock input (oscin) driven by external square wave. 3. no dc load or activity on i/o's; clock input (oscin) driven by external square wave. 4. except oscin and oscout 5. wait mode with slow mode selected. based on characterisation results, not tested. symbol parameter test conditions value unit min. typ. max. v il input low level voltage all input pins 3v < v dd < 5.5v v dd x 0.3 v v ih input high level voltage all input pins 3v < v dd < 5.5v v dd x 0.7 v v hys hysteresis voltage 1) all input pins 400 mv v ol low level output voltage all output pins i ol =+10 m a i ol = + 2ma 0.1 0.4 v low level output voltage high sink i/o pins i ol =+10 m a i ol = +10ma i ol = + 15ma i ol = + 20ma, t a =85 cmax 0.1 1.5 3.0 3.0 v oh high level output voltage all output pins i oh =-10 m a i oh = - 2ma 4.9 4.2 v i il i ih input leakage current all input pins but reset 4) v in =v ss (no pull-up configured) v in =v dd 0.1 1.0 m a i ih input leakage current reset pin v in =v dd 0.1 1.0 r on reset weak pull-up r on v in >v ih v in 74/84 st72101/st72212/st72213 6.4 reset characteristics (t a =-40...+125 o c and v dd =5v 10% unless otherwise specified. note: 1) these values given only as design guidelines and are not tested. 6.5 oscillator characteristics (t a = -40 c to +125 c unless otherwise specified) symbol parameter condition s min typ 1) max unit r on reset weak pull-up r on v in >v ih v in 75/84 st72101/st72212/st72213 6.6 a/d converter characteristics (st72212 and st72213 only) (t a = -40 c to +125 c and v dd =5v 10% unless otherwise specified ) *note : adc accuracy vs. negative injection current : for i inj- =0.8ma, the typical leakage induced inside the die is 1.6 m a and the effect on the adc accuracy is a loss of 1 lsb by 10k w increase of the external analog source impedance. these measurement results and recommendations take worst case injection conditions into account: - negative injection - injection to an input with analog capability, adjacent to the enabled analog input -at5vv dd supply, and worst case temperature. symbol parameter conditio ns min typ max unit t sample sample duration 31.5 1/f cpu res adc resolution f cpu =8mhz v dd =v dda =5v 8 bit dle differential linearity error* 0.6 1 ile integral linearity error* 2 v ain analog input voltage v ssa v dda v i adc supply current rise during a/d conversion f cpu =8mhz v dd =v dda =5v 1ma t stab stabilization time after adc enable 30 m s t conv conversion time 8 64 m s 1/f cpu r ain resistance of analog sources (v ain) f cpu =8mhz, t=25 c, v dd =v dda =5v 15 kw c hold hold capacitance 22 pf r ss resistance of sampling switch and internal trace 2 kw px.x/ainx r ain v ain c pin 5pf v dd v t = 0.6v leakage max. v t = 0.6v c pin v t leakage c hold ss sampling switch ss r ss at the pin due to various junctions c hold 22 pf capacitance = input capacitance = threshold voltage = sampling switch = sample/hold 1 m a v ss = leakage current 2 kw 75
76/84 st72101/st72212/st72213 a/d converter characteristics (cont'd) figure 42. adc conversion characteristics (2) (1) (3) (4) (5) vr02133a offset error ose offset error ose gain error ge 1 lsb (ideal) 1lsb ideal v refp v refm 256 --------------------------------------- - = v in(a) (lsb ideal ) (1) example of an actual transfer curve (2) the ideal transfer curve (3) differential non-linearity error (dle) (4) integral non-linearity error (ile) (5) center of a step of the actual transfer curve code out 255 254 253 252 251 250 5 4 3 2 1 0 7 6 1 2 3 4 5 6 7 250 251 252 253 254 255 256 76
77/84 st72101/st72212/st72213 6.7 spi characteristics measurement points are v ol ,v oh ,v il and v ih in the spi timing diagram figure 43. spi master timing diagram cpha=0, cpol=0 serial peripheral interface ref. symbol parameter condition value unit min. max. f spi spi frequency master slave 1/128 dc 1/4 1/2 f cpu 1t spi spi clock period master slave 4 2 t cpu 2t lead enable lead time slave 120 ns 3t lag enable lag time slave 120 ns 4t spi_h clock (sck) high time master slave 100 90 ns 5t spi_l clock (sck) low time master slave 100 90 ns 6t su data set-up time master slave 100 100 ns 7t h data hold time (inputs) master slave 100 100 ns 8t a access time (time to data active from high impedance state) slave 0 120 ns 9t dis disable time (hold time to high im- pedance state) 240 ns 10 t v data valid master (before capture edge) slave (after enable edge) 0.25 120 t cpu ns 11 t hold data hold time (outputs) master (before capture edge) slave (after enable edge) 0.25 0 t cpu ns 12 t rise rise time (20% v dd to 70% v dd ,c l = 200pf) outputs: sck,mosi,miso inputs: sck,mosi,miso, ss 100 100 ns m s 13 t fall fall time (70% v dd to 20% v dd ,c l = 200pf) outputs: sck,mosi,miso inputs: sck,mosi,miso, ss 100 100 ns m s 1 67 10 11 12 13 ss (input) sck (output) miso mosi (input) (output) 4 5 d7-out d6-out d0-out d7-in d6-in d0-in vr000109 77
78/84 st72101/st72212/st72213 spi characteristics (cont'd) measurement points are v ol ,v oh ,v il and v ih in the spi timing diagram figure 44. spi master timing diagram cpha=0, cpol=1 figure 45. spi master timing diagram cpha=1, cpol=0 figure 46. spi master timing diagram cpha=1, cpol=1 1 6 7 10 11 12 13 ss (input) sck (output) miso mosi (input) (outpu t) 4 5 vr000110 d7-out d6-out d0-out d7-in d6-in d0-in 1 6 7 10 11 12 13 ss (input) sck (output) miso mosi (input) (outpu t) 5 4 vr000107 d7-in d6-in d0-in d7-out d6-out d0-out 1 6 7 10 11 12 13 ss (input) sck (output) miso mosi (input) (output) 4 5 vr000108 d7-out d6-out d0-out d7-in d6-in d0-in
79/84 st72101/st72212/st72213 spi characteristics (cont'd) measurement points are v ol ,v oh ,v il and v ih in the spi timing diagram figure 47. spi slave timing diagram cpha=0, cpol=0 figure 48. spi slave timing diagram cpha=0, cpol=1 figure 49. spi slave timing diagram cpha=1, cpol=0 figure 50. spi slave timing diagram cpha=1, cpol=1 1 6 7 10 11 12 13 ss (input) sck miso mosi (input) (outpu t) 5 4 (input) 2 3 8 9 high-z vr000113 d7-in d6-in d0-in d7-out d6-out d0-out 1 6 7 10 11 12 13 ss (input) sck miso mosi (input) (outpu t) 54 (input) 2 3 8 9 high-z vr000114 d7-in d6-in d0-in d7-out d6-out d0-out 1 6 7 10 11 12 13 ss (input) sck miso mosi (input) (output) 5 4 (input) 2 3 8 9 high-z vr000111 d7-out d6-out d0-out d7-in d6-in d0-in 1 67 10 11 12 13 ss (input) sck miso mosi (input) (output) 54 (input) 2 3 8 9 high-z d7-out d6-out d0-out d7-in d6-in d0-in vr000112
80/84 st72101/st72212/st72213 7 general information 7.1 eprom erasure eprom version devices are erased by exposure to high intensity uv light admitted through the transparent window. this exposure discharges the floating gate to its initial state through induced photo current. it is recommended that the eprom devices be kept out of direct sunlight, since the uv content of sunlight can be sufficient to cause functional fail- ure. extended exposure to room level fluorescent lighting may also cause erasure. an opaque coating (paint, tape, label, etc...) should be placed over the package window if the product is to be operated under these lighting con- ditions. covering the window also reduces i dd in power-saving modes due to photo-diode leakage currents. an ultraviolet source of wave length 2537 ? yield- ing a total integrated dosage of 15 watt-sec/cm 2 is required to erase the device. it will be erased in 15 to 20 minutes if such a uv lamp with a 12mw/cm 2 power rating is placed 1 inch from the device win- dow without any interposed filters. 7.2 package mechanical data figure 51. 28-pin small outline package, 300-mil width dim. mm inches min typ max min typ max a 2.35 2.65 0.0926 0.1043 a1 0.10 0.30 0.0040 0.0118 b 0.33 0.51 0.013 0.020 c 0.23 0.32 0.0091 0.0125 d 17.70 18.10 0.6969 0.7125 e 7.40 7.60 0.2914 0.2992 e 1.27 0.0500 h 10.01 10.64 0.394 0.419 h 0.25 0.74 0.010 0.029 k 0 8 l 0.41 1.27 0.016 0.050 g 0.10 0.004 number of pins n28 so28
81/84 st72101/st72212/st72213 figure 52. 32-pin shrink plastic dual in line package figure 53. 32-pin shrink ceramic dual in-line package 1 n b d vr01725j n/2 b1 e a l see lead detail e 1 e 3 a 2 a 1 e c e b e a dim. mm inches min typ max min typ max a 3.56 3.76 5.08 0.140 0.148 0.200 a1 0.51 0.020 a2 3.05 3.56 4.57 0.120 0.140 0.180 b 0.36 0.46 0.58 0.014 0.018 0.023 b1 0.76 1.02 1.40 0.030 0.040 0.055 c 0.20 0.25 0.36 0.008 0.010 0.014 d 27.43 27.94 28.45 1.080 1.100 1.120 e 9.91 10.41 11.05 0.390 0.410 0.435 e1 7.62 8.89 9.40 0.300 0.350 0.370 e 1.78 0.070 ea 10.16 0.400 eb 12.70 0.500 l 2.54 3.05 3.81 0.100 0.120 0.150 number of pins n32 cdip32sw dim. mm inches min typ max min typ max a 3.63 0.143 a1 0.38 0.015 b 0.36 0.46 0.58 0.014 0.018 0.023 b1 0.64 0.89 1.14 0.025 0.035 0.045 c 0.20 0.25 0.36 0.008 0.010 0.014 d 29.41 29.97 30.53 1.158 1.180 1.202 d1 26.67 1.050 e 10.16 0.400 e1 9.45 9.91 10.36 0.372 0.390 0.408 e 1.78 0.070 g 9.40 0.370 g1 14.73 0.580 g2 1.12 0.044 l 3.30 0.130 7.37 0.290 number of pins n32
82/84 st72101/st72212/st72213 7.3 ordering information each device is available for production in user pro- grammable version (otp) as well as in factory coded version (rom). otp devices are shipped to customer with a default blank content ffh, while rom factory coded parts contain the code sent by customer. there is one common eprom version for debugging and prototyping which features the maximum memory size and peripherals of the family. care must be taken to only use resources available on the target device. 7.3.1 transfer of customer code customer code is made up of the rom contents and the list of the selected options (if any). the rom contents are to be sent on diskette, or by electronic means, with the hexadecimal file in .s19 format generated by the development tool. all un- used bytes must be set to ffh. the selected options are communicated to stmi- croelectronics using the correctly completed op- tion list appended. the stmicroelectronics sales organization will be pleased to provide detailed information on con- tractual points. figure 54. rom factory coded device types figure 55. otp user programmable device types note: the st72e251g2d0 (cerdip 25 c) is used as the eprom version for the above devices. device package temp. range xxx / code name (defined by stmicroelectronics) 1 = standard 0 to +70 c 3 = automotive -40 to +125 c 6 = industrial -40 to +85 c b = plastic dip m = plastic soic st72101g1 st72101g2 st72212g2 st72213g1 device package temp. range option (if any) 3 = automotive -40 to +125 c 6 = industrial -40 to +85 c b = plastic dip m = plastic soic st72t101g1 st72t101g2 st72t212g2 st72t213g1 xxx
83/84 st72101/st72212/st72213 st72101, st72213 and st72212 microcontroller option list customer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ............................. contact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phone no . . . . . . . . . . . . . . . . . . . . . . . . . . . . . reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . stmicroelectronics references device: [ ] st72101 [ ] st72212 [ ] st72213 package: [ ] dual in line plastic [ ] small outline plastic with conditioning: [ ] standard (stick) [ ] tape & reel temperature range: [ ] 0 cto+70 c []-40 cto+85 c[]-40 c to + 125 c special marking: [ ] no [ ] yes o_ _ _ _ _______o authorized characters are letters, digits, '.', '-', '/' and spaces only. maximum character count: sdip32: 10 so28: 8 comments: supply operating range in the application: oscillator frequency in the application: notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . date . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
84/84 st72101/st72212/st72213 8 summary of changes information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publication are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroelectronics. the st logo is a registered trademark of stmicroelectronics ? 1999 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - china - finland - france - germany - hong kong - india - italy - japan - malaysia - malta - morocco - singapore - spain sweden - switzerland - united kingdom - u.s.a. http:// www.st.com change description (rev. 1.5 to 1.6) page added new external connections section 9 removed rp external resistor 16 changed ored to anded in external interrupts paragraph, to read aif several input pins, con- nected to the same interrupt vector, are configured as interrupts, their signals are logically an- ded before entering the edge/level detection blocko. 18 and 24 added note oany modification of one of these two bits resets the interrupt request related to this interrupt vector.o 23 added clamping diodes to i/o pin figure and table 26 added sections on low power modes and interrupts to peripheral descriptions 31,43,58,63 changed 16-bit timer chapter 32 to 48 added details to description of folv1 and folv2 bits 44 added adc recommended external connections 63 added reset characteristics section 74 added figure to adc electrical characteristics section 75 change description (rev. 1.6 to 1.7) spr2 bit reinstated in spi chapter 49 to 61


▲Up To Search▲   

 
Price & Availability of ST72T101G1B3

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X